Lowest Common Multiple Plus
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 }