| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6127 人关注过本帖
标题:[讨论]第二期题目,大家做做.
取消只看楼主 加入收藏
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
结帖率:50%
收藏
 问题点数:0 回复次数:14 
[讨论]第二期题目,大家做做.

Least Common Multiple

--------------------------------------------------------------------------------

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 2373 Accepted Submit: 906

--------------------------------------------------------------------------------
The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.

Input

Input will consist of multiple problem instances. The first line of the input will contain a single integer indicating the number of problem instances. Each instance will consist of a single line of the form m n1 n2 n3 ... nm where m is the number of integers in the set and n1 ... nm are the integers. All integers will be positive and lie within the range of a 32-bit integer.


Output

For each problem instance, output a single line containing the corresponding LCM. All results will lie in the range of a 32-bit integer.


Sample Input

2
3 5 7 15
6 4 10296 936 1287 792 1


Sample Output

105
10296

求最小公倍数.

搜索更多相关主题的帖子: positive multiple example numbers Memory 
2006-11-19 16:01
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 

Digital Roots

--------------------------------------------------------------------------------

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 8841 Accepted Submit: 1989

--------------------------------------------------------------------------------

Background

The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.


Input

The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.


Output

For each integer in the input, output its digital root on a separate line of the output.


Example

Input

24
39
0
Output

6
3
这个题目比较简单,简单说一下:
给定一个数,求它的数根,即每一位的和组成一个新的数,直到所求的和是一个一位数为止.

求数根:例如39
是这样求到的39--->3+9=12--->1+2=3结束.
123456--->1+2+3+4+5+6=16=1+6=7结束.


倚天照海花无数,流水高山心自知。
2006-11-19 16:06
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
这些都没有,只要写个程序.提交后,它自动输入数据测试你的程序的正确性,不需要指定的文件.

倚天照海花无数,流水高山心自知。
2006-11-19 16:13
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
第二题好象在论坛里见过,不太清楚,大家做一下,比较简单.

如果不超过8个人做的话,下次我也懒得再发题目了,觉得没意思.
望大家原谅.

倚天照海花无数,流水高山心自知。
2006-11-19 17:07
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
以下是引用zhanghuan_10在2006-11-19 17:25:51的发言:

呵呵!我在论坛里发过第二道题!

大家快来做题啊!!!!

原来如此.

倚天照海花无数,流水高山心自知。
2006-11-19 21:22
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
第二个应该说很简单.
不过是字符串来接收,表示要处理的数,不用担心测试时会给你其它的字符.

gets(a);
int sum=0;
for(int i=0;i<strlen(a);i++)
{
sum+=a[i]-'0';
}
while(sum/10)
{
t=sum;
sum=0;
while(t)
{
sum+=t%10;
t/=10;
}
}
printf("%d\n",sum);

应该就可以了.

倚天照海花无数,流水高山心自知。
2006-11-20 21:38
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
以下是引用走刀口→超在2006-11-22 19:23:50的发言:

对于第1题,输入有点问题呀...不知道怎么控制了.怎么样都不行.

有谁写个输入的让我看看.我也把别人的代码回去瞅下.嘿嘿!

scanf("%d",&n);
while(n>0)
{
scanf("%d",&num);
max=0;
for(i=0;i<num;i++)
scanf("%ld",&a[i]);


倚天照海花无数,流水高山心自知。
2006-11-22 22:33
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
以下是引用weiwuchao在2006-11-23 9:48:13的发言:
#include <stdio.h>

int main(){
long int i=0;
long int j,k,p;
printf("plesse input a number\n"); //int put a positive number!warnning:smaller than 9999
scanf("%5d",&i);
for(;i>=10;){
j=i/1000; //j 是万位数字
k=(i%1000)/100; //j是千位数字
p=(i%100)/10; //p是个位数字
i=j+k+p;}
else return i; //输入小于十返回
printf("%5d",i); //输出结果

}


没有工具,不知道对不对

数还不够大.


倚天照海花无数,流水高山心自知。
2006-11-24 10:23
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
以下是引用少年包青蛙在2006-11-23 12:27:54的发言:

我也来做做第二题,因为简单嘛^_^


#include "stdio.h"
#include"string.h"
main()
{
int i,n,l,s,q,j,o=0;
char a[200],b[20],m;
scanf("%d",&n);
m=getchar();
for(i=0;i<n;i++)
{q=0;s=0;a[q]=getchar();
while(a[q]!='\n')
{
s=s+(int)a[q]-48;
a[++q]=getchar();}

while(s>9)s=s-9;//感觉你理解错了.
b[o++]=s;
}
for(i=0;i<n;i++)
printf("%d\n",b[i]);

}


倚天照海花无数,流水高山心自知。
2006-11-24 10:24
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 

感谢楼上的提出的建议.

1.这个不是竞赛贴,所以不存在奖励.即使说要有奖励,那怎么个奖励法,也不是我一个人说了算的.
2.的确,这些题目本身就是浙大ACM题.如果你们有自己的号,可以自己去做.
3.题目算是简单,但我也说过,这些不是竞赛题.再者,题目主要针对学C不是很久的朋友.一般有一个简单,一个稍微难点的.
如果出难的,我怕做的人也不是很多,这个就有违当时的初衷了.

谢谢.
希望大家对此有什么建议,我们都会考虑采纳.


倚天照海花无数,流水高山心自知。
2006-11-25 14:14
快速回复:[讨论]第二期题目,大家做做.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013039 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved