GCD AND LCM
Description
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b (0 < a, b ≤ 2,000,000,000). You can supporse that LCM(a, b) ≤ 2,000,000,000.10000000 150000000
//就是求最大公约数和最小公倍数
//我是先求出最大公约数,然后两个数的乘积再除以最大公约数就得到了最小公倍数了
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstdlib> #include<vector> typedef long long ll; ll gcd(ll x,ll y) { return y==0?x:gcd(y,x%y); } int main() { ll x,y; while(~scanf("%lld%lld",&x,&y)) { ll res1=gcd(x,y); printf("%lld %lld\n",res1,x*y/res1); } return 0; }用longlong,int不行,打印是%lld