HDOJ 1108 最小公倍数(水)

来源:互联网 发布:程序员招聘要求 编辑:程序博客网 时间:2024/05/20 16:43

【思路】:可移步至多个数的最小公倍数1019。

【AC代码】:

#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <cmath>#include <iomanip>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) {//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);int a = 0, b = 0;while (cin >> a >> b){int m = a, n = b;while (m!=n){if (m>n)m = m-n;elsen = n-m;} cout << a/m*b << endl;}return 0;}


0 0
原创粉丝点击