标签:des style blog class code java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31453 Accepted Submission(s): 12802
1 #include<stdio.h> 2 int gcd(int a,int b) 3 { 4 //辗转相除法 5 int temp; 6 if(a<b) 7 { 8 temp=a; 9 a=b; 10 b=temp; 11 } 12 if(a%b==0) 13 return b; 14 return gcd(b,a%b); 15 } 16 int main() 17 { 18 int a,b,n; 19 while(scanf("%d",&n)!=EOF) 20 { 21 scanf("%d\n",&a); 22 if(n==1) 23 printf("%d",a); 24 else 25 { 26 n--; 27 while(n--) 28 { 29 scanf("%d",&b); 30 //防止数据越界,先相除,再相乘 31 a=b/gcd(a,b)*a; 32 } 33 printf("%d\n",a); 34 } 35 } 36 return 0; 37 }
杭电acm2028--最小公倍数,布布扣,bubuko.com
标签:des style blog class code java
原文地址:http://www.cnblogs.com/-Unc/p/3714505.html