Pagini recente » Cod sursa (job #1792864) | Cod sursa (job #1532433) | Cod sursa (job #766176) | Istoria paginii tygyn/solutie_romana | Cod sursa (job #2713302)
#include <bits/stdc++.h>
using namespace std;
struct math {
int Tgcd(int a, int b) {
if (b == 0) {
return a;
} else {
return Tgcd(b, a % b);
}
}
int d = 0;
pair<int, int> gcd(int a, int b) {
if (b == 0) {
d = a;
return {1, 0};
} else {
pair<int, int> it = gcd(b, a % b);
return {it.second, it.first - a / b * it.second};
}
}
pair<int, int> coef(int a, int b, int c) {
auto it = gcd(a, b);
if (c % d) return {0, 0};
it.first *= (c / d);
it.second *= (c / d);
return it;
}
};
math user;
signed main() {
freopen ("euclid3.in", "r", stdin), freopen ("euclid3.out", "w", stdout);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
auto it = user.coef(a, b, c);
cout << it.first << " " << it.second << "\n";
}
}