Pagini recente » Cod sursa (job #1968722) | Cod sursa (job #239798) | Cod sursa (job #677012) | Cod sursa (job #2930778) | Cod sursa (job #1365256)
#include <iostream>
#include <fstream>
using namespace std;
inline int gcd(int a, int b, int &x, int &y) {
if(!b) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int g = gcd(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return g;
}
int main() {
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
fin >> t;
while(t -- ) {
int a, b, c;
fin >> a >> b >> c;
int x, y;
int g = gcd(a, b, x, y);
if(c % g) {
fout << "0 0\n";
continue;
}
fout << x * (c / g) << ' ' << y * (c / g) << '\n';
}
}