Pagini recente » Cod sursa (job #1668109) | Cod sursa (job #2711921) | Cod sursa (job #2327957) | Cod sursa (job #6433) | Cod sursa (job #2429829)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int a, b, c, x, y, t;
int euclid(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int X, Y, D;
D = euclid(b, a%b, X , Y);
x = Y;
y = X - (a / b) * Y;
return D;
}
int main()
{
f >> t;
for(; t; t--)
{
f >> a >> b >> c;
int d = euclid(a, b, x, y);
if(c % d)
g << "0 0\n";
else
g << c / d * x << ' ' << c / d * y << '\n';
}
return 0;
}