#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b){
return b == 0 ? a : gcd(b,a%b);
}
long long lcm(long long a, long long b){
return a*b/gcd(a,b);
}
int main(){
long long n , m;
while(~scanf("%lld %lld", &n, &m)){
long long l = lcm(n-1,m-1);
long long a = l/(m-1) , b = l/(n-1);
printf("%lld\n",l - a*b + a + b);
}
return 0;
}
hihocoder 1584 Bounce
Guess you like
Origin www.cnblogs.com/lizehon/p/11273092.html
Recommended
Ranking