From ebbacd0e8946b1a7fc73abeb479bb5b600e3d138 Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Thu, 28 Apr 2016 08:26:59 +0800 Subject: [PATCH] Create 1721.c --- QUSTOJ/1721.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 QUSTOJ/1721.c diff --git a/QUSTOJ/1721.c b/QUSTOJ/1721.c new file mode 100644 index 0000000..5fdfd82 --- /dev/null +++ b/QUSTOJ/1721.c @@ -0,0 +1,37 @@ +#include +#include +#include +//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; +}