51nod_1012 最小公倍数LCM
2017-04-24 11:08
267 查看
1012 最小公倍数LCM
基准时间限制:1 秒 空间限制:131072 KB 分值: 0
输入2个正整数A,B,求A与B的最小公倍数。
Input
2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)
Output
输出A与B的最小公倍数。
Input示例
30 105
Output示例
210
代码:
基准时间限制:1 秒 空间限制:131072 KB 分值: 0
输入2个正整数A,B,求A与B的最小公倍数。
Input
2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)
Output
输出A与B的最小公倍数。
Input示例
30 105
Output示例
210
代码:
#include<cstdio> #include<iostream> using namespace std; typedef long long LL; LL gcd(LL a,LL b){ if(b==0) return a; gcd(b,a%b); } int main(){ LL a,b; cin>>a>>b; LL t=gcd(a,b); LL lcm=(a*b)/t; cout<<lcm<<endl; return 0; }
相关文章推荐
- 51Nod-1012 最小公倍数LCM【欧几里得算法】
- 51Nod 1012 最小公倍数LCM
- 51nod 1012 最小公倍数LCM【数论】
- 【51NOD-0】1012 最小公倍数LCM
- 51Nod-1012-最小公倍数LCM
- 【51nod】1012 最小公倍数LCM - 辗转相除法
- 最小公倍数LCM 51Nod - 1012
- 【GCD|LCM】最大公约数和最小公倍数问题 WIKIOI1012
- 1012 最小公倍数LCM(51NOD基础题)
- codevs 1012 NOIP 2001 最大公约数和最小公倍数问题
- 51Nod-1419-最小公倍数挑战
- k个数中求任意k-1个数的最小公倍数(LCM)的最小值
- CODE[VS]1012 最大公约数和最小公倍数问题
- 【51nod 2026】Gcd and Lcm
- Minimum Sum LCM UVA - 10791 (唯一分解定理+最小公倍数和其联系)
- 九度oj 最大公约数(gcd)(这缩写!!!) 最小公倍数(lcm) 1056,1438,1439
- Code Vs-problem-1012 最大公约数和最小公倍数问题
- CODEVS 1012 最大公约数和最小公倍数问题
- 51nod 1434 理解lcm
- 求两个或N个数的最大公约数(gcd)和最小公倍数(lcm)的较优算法