Pagini recente » Cod sursa (job #3217340) | Cod sursa (job #721860) | Cod sursa (job #836418) | Cod sursa (job #698739) | Cod sursa (job #2854208)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int Euclid_extins(int a, int b, int& x, int& y) {
if (b == 0) {
x = 1, y = 0;
return a;
}
else {
int x0, y0, d;
d = Euclid_extins(b, a % b, x0, y0);
x = y0, y = x0 - (a / b) * y0;
}
}
int t;
int main() {
cin >> t;
for (int i = 1, a, b, c, d, x, y; i <= t; ++i) {
cin >> a >> b >> c, d = Euclid_extins(a, b, x, y);
if (c % d == 0)
cout << x * c / d << " " << y * c / d << "\n";
else
cout << 0 << " " << 0 << "\n";
}
return 0;
}