Pagini recente » Cod sursa (job #989173) | Cod sursa (job #2559075) | Cod sursa (job #912279) | Cod sursa (job #935364) | Cod sursa (job #2970526)
#include <bits/stdc++.h>
using namespace std;
ifstream r("euclid3.in");
ofstream w("euclid3.out");
int euclid(int a, int b, int &x, int &y)
{
if(!b)
{
x = 1;
y = 0;
return a;
}
int x0, y0;
int c = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - y0 * (a / b);
return c;
}
void solve()
{
int n, a, b, c, d, x, y;
r>>n;
for(int i = 1; i <= n; i++)
{
r>>a>>b>>c;
d = euclid(a, b, x, y);
if(!(c % d))
{
w << x * (c / d) << " " << y * (c / d) << "\n";
}
else
{
w<<"0 0\n";
}
}
}
int main()
{
solve();
return 0;
}