Pagini recente » Cod sursa (job #2083687) | Cod sursa (job #221988) | Cod sursa (job #3262367) | Cod sursa (job #3242603) | Cod sursa (job #3232089)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n, a, b, c, d, x, y;
static inline int Euclid(int a, int b, int &x, int &y) {
if(b == 0) {
x = 1;
y = 0;
return a;
}
else {
int x1, y1;
int d = Euclid(b, a % b, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
return d;
}
}
int main() {
fin >> n;
while(n--) {
fin >> a >> b >> c;
d = Euclid(a, b, x, y);
if(c % d == 0) fout << x * (c / d) << " " << y * (c / d) << "\n";
else fout << "0 0\n";
}
return 0;
}