Create 1863.cpp

pull/45/head
Kirigaya Kazuto 2016-10-24 16:37:12 +08:00 committed by GitHub
parent 002b8598ba
commit ad81a47613
1 changed files with 35 additions and 0 deletions

35
QUSTOJ/1863.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
using namespace std;
//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;
cin>>a>>b;
int c=gcd(a,b);
cout<<c<<" "<<a*b/c<<endl;
return 0;
}