Pagini recente » Cod sursa (job #1768614) | Borderou de evaluare (job #570709) | Borderou de evaluare (job #1900479) | Borderou de evaluare (job #1292474) | Cod sursa (job #2917455)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void euclid(int a, int b, int& d, int& x, int& y) {
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
int x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main() {
int t, a, b, c, x, y, k, d = 1;
f >> t;
for (short i = 0; i < t; i++) {
f >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d != 0)
g << 0 << " " << 0 << "\n";
else {
k = c / d;
g << x * k << " " << y * k << "\n";
}
}
return 0;
}