Pagini recente » Cod sursa (job #3146192) | Cod sursa (job #1217842) | Cod sursa (job #2988072) | Cod sursa (job #521997) | Cod sursa (job #1067554)
#include <fstream>
using namespace std;
int gcd(int a,int b,int &x,int &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int ret = gcd(b,a % b,x,y);
int temp = x;
x = y;
y = temp - (a / b) * y;
return ret;
}
int main()
{
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int testCount, a, b, c;
int Gcd, x, y;
for (cin >> testCount;testCount;testCount--) {
cin >> a >> b >> c;
Gcd = gcd(a,b,x,y);
if (c % Gcd) {
cout << "0 0\n";
} else {
cout << x * (c / Gcd) << " " << y * (c / Gcd) << "\n";
}
}
return 0;
}