Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long long x,y;
- cin>>x>>y;
- if(x>y)
- swap(x,y);
- if(2*x>y)
- cout<<(x/(y-x)+1)*(y-x)-x;
- else
- {
- long long dif=y-x;
- long long k=dif/x;
- for(;k&&dif%k;--k);
- cout<<dif/k-x;
- }
- }
Add Comment
Please, Sign In to add comment