(a,b)×[a,b]=a×b
证明:
记
a=i=1∏kpiαi,b=i=1∏kpiβi
则有:
(a,b)×[a,b]=(i=1∏kpimin(αi,βi))×(i=1∏kpimax(αi,βi))=i=1∏kpimin(αi,βi)+max(αi,βi)=i=1∏kpi(αi+βi)=a×b
注意开 __int128
即可。
#include<cstdio>
#define int __int128
int init(){
char c = getchar();
int x = 0, f = 1;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') f = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = (x << 1) + (x << 3) + (c ^ 48);
return x * f;
}
void print(int x){
if (x < 0) x = -x, putchar('-');
if (x > 9) print(x / 10);
putchar(x % 10 + '0');
}
int gcd(int a, int b){
return b ? gcd(b, a % b) : a;
}
signed main(){
int a = init(), b = init();
print(a / gcd(a, b) * b), putchar('\n');
}