Pagini recente » Cod sursa (job #927715) | Cod sursa (job #3283816) | Cod sursa (job #3278344) | Cod sursa (job #2930839)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int euclid(int a, int b, int &x, int &y) {
if(!b) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int c = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - y0 * (a / b);
return c;
}
void solve() {
int n, a, b, c, d, x, y;
f>>n;
for(int i = 1;i <= n;++i) {
f>>a>>b>>c;
d = euclid(a, b, x, y);
if(!(c % d)) {
g << x * (c / d) << " " << y * (c / d) << '\n';
}
else {
g<<"0 0\n";
}
}
}
int main() {
solve();
return 0;
}