Pagini recente » Cod sursa (job #1687775) | Cod sursa (job #2979434) | Cod sursa (job #719970) | Cod sursa (job #3139080) | Cod sursa (job #2409995)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1025;
int dp[MAXN][MAXN];
int gcd(int a, int b, int &x, int &y) {
if(!b){
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = gcd(b, a%b, x0, y0);
x = y0;
y = x0 - (a/b)*y0;
return d;
}
int main() {
#ifdef BLAT
freopen("input", "r", stdin);
#else
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--) {
int a, b, c;
cin >> a >> b >> c;
int d, x, y;
d = gcd(a, b, x, y);
if(c % d) {
cout << "0 0\n";
} else cout << x*(c/d) << ' ' << y*(c/d) << '\n';
}
return 0;
}