Pagini recente » Diferente pentru olimpici intre reviziile 180 si 81 | Statistici Pava David-Daniel (bosskyboss) | Cod sursa (job #1240146) | Cod sursa (job #2012228) | Cod sursa (job #1218751)
#include <iostream>
using namespace std;
void gcd(long long &x, long long &y, long long a, long long b, long long &d) {
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
long long x0, y0;
gcd(x0, y0, b, a%b, d);
x = y0;
y = x0 - a/b*y0;
}
}
int main() {
long long t, a, b, c, d, x, y;
freopen("euclid3.in", "r", stdin);
//freopen("input.txt","r",stdin);
freopen("euclid3.out", "w", stdout);
cin >> t;
while(t--) {
cin >> a >> b >> c;
gcd(x, y, a, b, d);
if (c % d == 0) {
cout << x * (c/d) << " " << y * (c/d) << "\n";
} else {
cout << "0 0\n";
}
}
return 0;
}