Pagini recente » Cod sursa (job #2459188) | Cod sursa (job #270510) | Cod sursa (job #3235125) | Cod sursa (job #2310763) | Cod sursa (job #2723276)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int gcdExtended(int a, int b, int &x1, int &y1)
{
if(b == 0)
{
x1 = 1;
y1 = 0;
return a;
}
else
{
int x, y;
int w = gcdExtended(b, a % b, x, y);
x1 = y;
y1 = x - (a / b) * y;
return w;
}
}
int main()
{
int n;
cin>>n;
for(int i = 1; i <= n; ++i)
{
int a,b,c;
cin >> a >> b >> c;
int x, y;
int d = gcdExtended(a, b, x, y);
if(c % d == 0)
cout << x*(c / d) << ' ' << y*(c / d) << '\n';
else cout << "0 0\n";
}
return 0;
}