HDOJ2028 ( Lowest Common Multiple Plus )

简介:
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
复制代码
 1 #include <stdio.h>
 2 int lcm(int a,int b)
 3 {
 4     int min,max,ret;
 5     min=a>b?b:a;
 6     max=a>b?a:b;
 7     ret=max;
 8     while (ret%min!=0)    ret+=max;
 9     return ret;
10 
11 }
12 int main()
13 {
14     int r,n,i;
15     while (scanf("%d",&n)!=EOF)
16     {
17         r=1;
18         while (n--)
19         {
20             scanf("%d",&i);
21             r=lcm(i,r);
22         }
23         printf("%d\n",r);
24     }
25     return 0;
26 }
复制代码

 


本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/05/26/2519051.html,如需转载请自行联系原作者

相关文章
|
6月前
hdu 1019 Least Common Multiple
hdu 1019 Least Common Multiple
29 0
hdu 1019 Least Common Multiple
hdu 1019 Least Common Multiple
31 0
《Towards A Fault-Tolerant Speaker Verification System A Regularization Approach To Reduce The Condition Number》电子版地址
Towards A Fault-Tolerant Speaker Verification System: A Regularization Approach To Reduce The Condition Number
86 0
《Towards A Fault-Tolerant Speaker Verification System A Regularization Approach To Reduce The Condition Number》电子版地址
PAT (Advanced Level) Practice - 1143 Lowest Common Ancestor(30 分)
PAT (Advanced Level) Practice - 1143 Lowest Common Ancestor(30 分)
118 0
|
Java
HDU - 2018 Multi-University Training Contest 1 - 1001: Maximum Multiple
HDU - 2018 Multi-University Training Contest 1 - 1001: Maximum Multiple
97 0
PAT (Advanced Level) Practice - 1096 Consecutive Factors(20 分)
PAT (Advanced Level) Practice - 1096 Consecutive Factors(20 分)
145 0
HDOJ1019Least Common Multiple
HDOJ1019Least Common Multiple
97 0
HDOJ 1019 Least Common Multiple(最小公倍数问题)
HDOJ 1019 Least Common Multiple(最小公倍数问题)
95 0
HDOJ 2028 Lowest Common Multiple Plus(n个数的最小公倍数)
HDOJ 2028 Lowest Common Multiple Plus(n个数的最小公倍数)
127 0