Pagini recente » Cod sursa (job #184743) | Cod sursa (job #2974567) | Cod sursa (job #2191617) | Cod sursa (job #450769) | Cod sursa (job #2046336)
#include <bits/stdc++.h>
using namespace std;
int solve(int a, int b, int &x, int &y){
if(b == 0){
x = 1;
y = 0;
return a;
}
int x0, y0;
int ret = solve(b, a%b, x0, y0);
x = y0;
y = x0 - (a/b) * y0;
return ret;
}
int main()
{
int T;
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d", &T);
while(T--){
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int d, x, y;
d = solve(a, b, x, y);
if(c%d != 0){
printf("0 0\n");
}else{
printf("%lld %lld\n", 1LL * x * c / d, 1LL * y * c / d);
}
}
return 0;
}