Pagini recente » Cod sursa (job #2948572) | Cod sursa (job #2544365) | Cod sursa (job #2544354) | Cod sursa (job #1216292) | Cod sursa (job #1679378)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
void gcd(int a, int b, int &x, int &y, int &d) {
if(b == 0) {
d = a;
x = 1;
y = 0;
return;
}
int x0,y0;
gcd(b, a%b, x0, y0, d);
x = y0;
y = x0 - (a/b)*y0;
}
int main() {
int n,a,b,c,d,x,y;
in >> n;
for(int i = 0; i < n; i++) {
in >> a >> b >> c;
gcd(a, b, x, y, d);
if(c % d != 0) {
out << 0 << " " << 0 << '\n';
} else {
out << x * (c/d) << " " << y * (c/d) << '\n';
}
}
return 0;
}