Pagini recente » Cod sursa (job #1517834) | Cod sursa (job #2961087) | Cod sursa (job #603130) | Cod sursa (job #2966039) | Cod sursa (job #2854202)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
void Euclid_extins(int a, int b, int& d, int& x, int& y) {
if (b == 0)
d = a, x = 1, y = 0;
else {
int x0, y0;
Euclid_extins(b, a % b, d, 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=0,x=0,y=0, Euclid_extins(a, b, d, x, y);
if (c % d == 0)
cout << x * c / d << " " << y * c / d << "\n";
else
cout << 0 << " " << 0 << "\n";
}
return 0;
}