Saleh127

uva 10104

Jun 22nd, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int gcd(int a, int c, int& x, int& y)
  7. {
  8. if (c == 0)
  9. {
  10. x = 1;
  11. y = 0;
  12. return a;
  13. }
  14. int x1, y1;
  15. int d = gcd(c, a % c, x1, y1);
  16. x = y1;
  17. y = x1 - y1 * (a / c);
  18. return d;
  19. }
  20. int main()
  21. {
  22. fellow_junior
  23.  
  24. int a,c,d,i,j;
  25. while(cin>>a>>c && a && c)
  26. {
  27. int x,y;
  28. j=gcd(a,c,x,y);
  29. cout<<x<<" " <<y<<" "<<j<<endl;
  30. }
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment