Pagini recente » Cod sursa (job #3340532) | Cod sursa (job #3319042) | Cod sursa (job #3343565) | Monitorul de evaluare | Cod sursa (job #3323010)
#include <fstream>
using namespace std;
int euclid(int a, int b, int &x, int &y){
int x1, y1, g;
if (b == 0){
y = 0;
x = 1;
return a;
}
g = euclid(b, a % b, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
return g;
}
int main()
{
ifstream cin ("euclid3.in");
ofstream cout ("euclid3.out");
int t, a, b, c, g, x, y;
cin >> t;
while (t--){
cin >> a >> b >> c;
g = euclid(a, b, x, y);
if (c % g != 0)
cout << 0 << ' ' << 0 << '\n';
else
cout << x * (c / g) << ' ' << y * (c / g) << '\n';
}
return 0;
}