fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long n,m,x;
  4. int main(){
  5. cin>>n>>m;
  6. x=m/__gcd(n,m);
  7. cout<<(x-1)*__gcd(n, m);
  8. }
  9.  
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
Standard output is empty