首页 > 其他 > 详细

蓝桥杯 历届试题 核桃的数量

时间:2017-02-26 15:15:32      阅读:126      评论:0      收藏:0      [点我收藏+]

最小公倍数,a,b,最小公倍数为a*b/gcd(a,b)

 1 #include<iostream>
 2 
 3 using namespace std;
 4 
 5 int gcd(int a,int b)
 6 {
 7     if(a<b)
 8     {
 9         int temp=b;
10         b=a;
11         a=temp;
12     }
13     int c;
14     while(b)
15     {
16         c=a%b;
17         a=b;
18         b=c;
19     }
20     return a;
21 }
22 int main()
23 {
24     int a,b,c;
25     while(cin>>a>>b>>c)
26     {
27         int temp=a*b/gcd(a,b);
28         int ans=temp*c/gcd(temp,c);
29         cout<<ans<<endl;
30     }
31     return 0;
32 }

 

蓝桥杯 历届试题 核桃的数量

原文:http://www.cnblogs.com/Xycdada/p/6444316.html

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