Pagini recente » Cod sursa (job #137088) | Cod sursa (job #2249309) | Cod sursa (job #1311834) | Cod sursa (job #2360430) | Cod sursa (job #1266435)
#include <iostream>
#include <fstream>
std::ifstream f("euclid3.in");
std::ofstream g("euclid3.out");
void extins(int a, int b, int &x, int &y, int &d) {
if (b == 0) {
x = 1;
y = 0;
d = a;
}
else {
int nx, ny;
extins(b, a % b, nx, ny, d);
x = ny;
y = nx - (a / b) * ny;
}
}
int main()
{
int t;
f >> t;
for (int i = 1; i <= t; i++) {
int a, b, c, d = 0, x = 0, y = 0;
f >> a >> b >> c;
extins(a, b, x, y, d);
if (c % d == 0) {
g << x * (c / d) << ' ' << y * (c / d) << '\n';
}
else {
g << "0 0\n";
}
}
f.close();
g.close();
return 0;
}