首页 > 其他 > 详细

HDU 2028 Lowest Common Multiple Plus

时间:2015-10-26 00:32:37      阅读:205      评论:0      收藏:0      [点我收藏+]

Lowest Common Multiple Plus

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 42356    Accepted Submission(s): 17505

Problem Description
求n个数的最小公倍数。
 
Input
输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。
 
Output
为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。
 
Sample Input
2 4 6 3 2 5 7
 
Sample Output
12 70
 
Author
lcy
 1 #include<stdio.h>
 2 int main (void)
 3 {
 4     int a[500];
 5     int i, n, temp;
 6     while(scanf("%d", &n) == 1){
 7         temp = 0;
 8         for(i = 1; i <= n; i++){
 9             scanf("%d", &a[i]);
10             if(temp < a[i])
11                 temp = a[i]; 
12         }
13         for(i = 1; i <= n; i++)
14             if(temp % a[i] != 0){
15                 temp++;
16                 i = 0; 
17             }
18         printf("%d\n", temp);
19     }
20     return 0;
21 }

 

 

HDU 2028 Lowest Common Multiple Plus

原文:http://www.cnblogs.com/clairvoyant/p/4909925.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!