Pagini recente » Cod sursa (job #1772125) | Cod sursa (job #1945158) | Cod sursa (job #795753) | Cod sursa (job #2457813) | Cod sursa (job #3249947)
#include <iostream>
#include <fstream>
void gcd(int& x, int& y, int& d, int a, int b) {
if (b == 0) {
x = 1;
y = 0;
d = a;
return;
}
gcd(x, y, d, b, a % b);
int temp = x;
x = y;
y = temp - (a / b) * y;
}
int main (int argc, char *argv[]) {
std::ifstream fin("euclid3.in");
std::ofstream fout("euclid3.out");
int T;
fin >> T;
for (int i = 0; i < T; i++) {
int a, b, c;
fin >> a >> b >> c;
int x, y, d;
gcd(x, y, d, a, b);
if (c % d) fout << 0 << " " << 0;
else fout << x*(c / d) << " " << y * (c / d);
fout << "\n";
}
return 0;
}