Create 1352.cpp

This commit is contained in:
Kirigaya Kazuto 2016-05-23 12:44:34 +08:00
parent 82c412531b
commit f0da649615

34
QUSTOJ/1352.cpp Normal file
View File

@ -0,0 +1,34 @@
#include <cstdio>
//Written by Kiritow. 求最大公约数
long gcd(long a,long b)
{
if(a==0||b==0)
{
if(a+b==0)
{
return 0;
}
return (a==0)?b:a;
}
while(a!=b)
{
if(a>b)
{
a=a-b;
}
else
{
b=b-a;
}
}
return a;
}
int main()
{
int a,b;
scanf("%d%d",&a,&b);
long s=gcd(a,b);
printf("%ld %ld\n",s,a*b/s);
return 0;
}