最小公倍数
来源:互联网 发布:java中逻辑或 编辑:程序博客网 时间:2024/06/11 16:25
最小公倍数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5386 Accepted Submission(s): 3751Problem Description
给定两个正整数,计算这两个数的最小公倍数。
Input
输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.
Output
对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。
Sample Input
10 14
Sample Output
70
Source
POJ
#include <iostream>using namespace std;int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}int main(){int n,m;while(cin>>n>>m){
cout<<n*m/gcd(n,m)<<endl;} return 0;}
阅读全文
0 0
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- 最小公倍数
- Redis笔记
- I2C的传输速率由什么决定
- Redis LRU
- 设计模式(2)
- BZOJ2521: [Shoi2010]最小生成树
- 最小公倍数
- 152. Maximum Product Subarray
- liunx的awk命令
- Java Web中前台与后台传递参数小结
- BeaEngine反汇编引擎在C中的使用
- script三种加载方式
- 常用git 命令
- LeetCode 100. Same Tree(二叉树)
- 巴士博弈 【总结】