Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <tuple>
- using namespace std;
- tuple<int, int, int> gcd(int a, int b)
- {
- if (b == 0)
- return make_tuple(a, 1, 0);
- int x1, y1, d;
- tie(d, x1, y1) = gcd(b, a % b);
- int x = y1;
- int y = x1 - (a / b) * y1;
- return make_tuple(d, x, y);
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int a, b, c;
- cin >> a >> b >> c;
- int x1, y1, d;
- tie(d, x1, y1) = gcd(a, b);
- if (c % d != 0)
- {
- cout << "Impossible";
- return 0;
- }
- cout << d << " " << x1 * (c / d) << " " << y1 * (c / d);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement