标签:最大 code src 技术分享 else print scan iostream inf
#include<algorithm>
#include<iostream>
using namespace std;
int gcd(int a,int b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
int main(){
int t;
long long n,m;
cin>>t;
while(t--){
cin>>n>>m;
cout<<n /gcd(n,m) * m<<endl;
}
}
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
//辗转相减法 求最大公约数
long long int measure(int a,int b)
{
while(a != b)
{
if(a>b)
{
a = a - b;
}
else
{
b = b - a;
}
}
return a;
}
int main ()
{
long long int n;
cin>>n;
while(n--)
{
long long int n,m;
scanf("%lld %lld",&n,&m);
printf("%lld\n",(n*m)/measure(n,m));
}
return 0 ;
}
标签:最大 code src 技术分享 else print scan iostream inf
原文地址:https://www.cnblogs.com/fisherss/p/9985461.html