From f0da649615a6d258703aa58242d7482bce69632d Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Mon, 23 May 2016 12:44:34 +0800 Subject: [PATCH] Create 1352.cpp --- QUSTOJ/1352.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 QUSTOJ/1352.cpp diff --git a/QUSTOJ/1352.cpp b/QUSTOJ/1352.cpp new file mode 100644 index 0000000..3fe3ca8 --- /dev/null +++ b/QUSTOJ/1352.cpp @@ -0,0 +1,34 @@ +#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); + long s=gcd(a,b); + printf("%ld %ld\n",s,a*b/s); + return 0; +}