Advertisement
Saleh127

Untitled

Apr 18th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long a,b,c,d,e=0,f=0,i,j,k=0,l;
  6. cin>>a>>b;
  7. cin>>c>>d;
  8. for(; b<100000;)
  9. {
  10. if(b==d)
  11. {
  12. cout<<b<<endl;
  13. return 0;
  14. }
  15. else if(b<d) b+=a;
  16. else d+=c;
  17. }
  18. cout<<-1<<endl;
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement