Pagini recente » Cod sursa (job #2499700) | Cod sursa (job #1559625) | Cod sursa (job #592838) | Cod sursa (job #1346816) | Cod sursa (job #3155136)
#include <fstream>
#include <iostream>
using namespace std;
/*
(a, b, c) => (x, y) ?
T - no tests [1, 100]
a, b -> [-1 000 000 000, 1 000 000 000]
c -> [-2 000 000 000, 2 000 000 000]
x, y -> [-2 000 000 000, 2 000 000 000]
*/
int cmmdc(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int d = cmmdc(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
ifstream read("euclid3.in");
ofstream write("euclid3.out");
int T;
read >> T;
while (T > 0) {
int a, b, c, x, y;
read >> a >> b >> c;
int d = cmmdc(a, b, x, y);
if (c % d != 0) {
write << "0 0\n";
} else {
write << x * (c / d) << " " << y * (c / d) << "\n";
}
T--;
}
return 0;
}