Create 1732.c

pull/14/head
Kirigaya Kazuto 2016-05-21 12:38:51 +08:00
parent 8d8b5c7762
commit 90b00e292b
1 changed files with 34 additions and 0 deletions

34
QUSTOJ/1732.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
//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);
int ans=gcd(a,b);
printf("最大公约数:%d\n最小公倍数:%d\n",ans,a*b/ans);
return 0;
}