cf Good Bye 2023 B. Two Divisors
作者:
さのpool
,
2024-01-02 21:16:45
,
所有人可见
,
阅读 98
如果有大佬会证明可以指导一下我
需要特判为约数的情况(比赛的时候真没想到怎么处理)
还需要证明为什么的,这几天被华科的一张数学卷子虐了,状态很差,过几天吧。。。
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
void solve()
{
int a,b;
scanf("%d%d",&a,&b);
int t = gcd(a,b);
if(a<b)swap(a,b);
if(!(a%b)) printf("%d\n",a/t*b*(a/b));
else printf("%d\n",a/t*b);
}
int main()
{
cin>>n;
while (n -- ){
solve();
}
return 0;
}