#include<iostream>
using namespace std;
int main()
{
int gcd(int a,int b);//求最大公约数
int a,b,t,p;
cin>>t;
while(t--)
{
cin>>a>>b;
p = gcd(a,b);
cout<<p<<' '<<a*b/p<<endl;
}
return 0;
}
int gcd(int a,int b)
{
if (a<b)//交换a,b
{
a = a^b;
b = a^b;
a = a^b;
}
while(b!=0)
{
a = a%b;
a = a^b;
b = a^b;
a = a^b;
}
return a;
}
NYOJ40-公约数和公倍数
最新推荐文章于 2019-03-30 21:35:19 发布