hdu 1108 最小公倍数

Problem Description

给定两个正整数,计算这两个数的最小公倍数。

Input

输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.

Output

对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。

Sample Input

10 14

Sample Output

70
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

const double inf=1e20;
const int maxn=1e5+10;
const int mod=1e9+7;

ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

int main(){
    ll n,m;
    while(scanf("%lld%lld",&n,&m)!=EOF){
        printf("%lld\n",lcm(n,m));
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/wz-archer/p/12405582.html