a53

adun

a53
Apr 10th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. long long x,y;
  7. cin>>x>>y;
  8. if(x>y)
  9. swap(x,y);
  10. if(2*x>y)
  11. cout<<(x/(y-x)+1)*(y-x)-x;
  12. else
  13. {
  14. long long dif=y-x;
  15. long long k=dif/x;
  16. for(;k&&dif%k;--k);
  17. cout<<dif/k-x;
  18. }
  19. }
Add Comment
Please, Sign In to add comment