Pagini recente » Cod sursa (job #3272976) | Cod sursa (job #2616547) | Cod sursa (job #235484) | Cod sursa (job #1195300) | Cod sursa (job #3264550)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int &d, int &x, int &y) {
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
int x1, y1;
euclid(b, a % b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int main() {
int t;
fin >> t;
while (t--) {
int a, b, c;
fin >> a >> b >> c;
int d;
int x, y;
euclid(a, b, d, x, y);
if (c % d) {
fout << 0 << ' ' << 0 << '\n';
} else {
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
}
return 0;
}