Pagini recente » Cod sursa (job #3263089) | Cod sursa (job #3244583) | Cod sursa (job #3291664) | Cod sursa (job #3215727) | Cod sursa (job #3290456)
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
long long ext_gcd(long long a, long long b, long long& x, long long& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
else {
long long nx, ny, g;
g = ext_gcd(b, a % b, nx, ny);
x = ny;
y = nx - a / b * x;
return g;
}
}
int main() {
FILE* fin = fopen("euclid3.in", "r");
FILE* fout = fopen("euclid3.out", "w");
int T;
fscanf(fin, "%ld", &T);
for (int t = 0; t < T; ++t) {
long long a, b, c, x, y;
fscanf(fin, "%ld %ld %ld", &a, &b, &c);
long long g = ext_gcd(a, b, x, y);
if (c % g) {
fprintf(fout, "%ld %ld\n", 0, 0);
}
else {
x *= c / g;
y *= c / g;
fprintf(fout, "%ld %ld\n", x, y);
}
}
}