Pagini recente » Cod sursa (job #1113847) | Cod sursa (job #1304335) | Cod sursa (job #2255742) | Cod sursa (job #1000856) | Cod sursa (job #1360073)
#include<cstdio>
#include<string>
using namespace std;
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "euclid3";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
typedef long long int lld;
int T;
lld euclid(lld a, lld b, lld &x, lld &y) {
if(b == 0) {
x = 1;
y = 0;
return a;
}
lld x0, y0;
lld d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
lld a, b, c, d, x, y;
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
scanf("%d", &T);
while(T--) {
scanf("%lld%lld%lld", &a, &b, &c);
d = euclid(a, b, x, y);
if(c % d)
x = y = 0;
else {
x *= (c / d);
y *= (c / d);
}
printf("%lld %lld\n", x, y);
}
return 0;
}