Pagini recente » Cod sursa (job #1541570) | Cod sursa (job #2248412) | Cod sursa (job #272123) | Cod sursa (job #2553885) | Cod sursa (job #1174034)
#include <fstream>
using namespace std;
int Euclid(const int a, const int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int nx, ny;
int d = Euclid(b, a % b, nx, ny);
x = ny;
y = nx - (a / b) * ny;
return d;
}
int main() {
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int tests;
cin >> tests;
for (; tests > 0; --tests) {
int a, b, c;
cin >> a >> b >> c;
int x, y;
int d = Euclid(a, b, x, y);
if (c % d != 0)
cout << "0 0\n";
else
cout << x * (c / d) << " " << y * (c / d) << "\n";
}
cin.close();
cout.close();
return 0;
}