Pagini recente » Cod sursa (job #1230767) | Cod sursa (job #3171305) | Cod sursa (job #1621085) | Cod sursa (job #557091) | Cod sursa (job #1825927)
#include <iostream>
#include <fstream>
using namespace std;
int euclid(int a, int b, int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
int x0, y0, d;
d=euclid(b,a%b,x0,y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int a, b, c, x, y, t;
fin >> t;
while(t)
{
fin >> a >> b >> c;
int d=euclid(a,b,x,y);
if(c%d) fout << 0 << " " << 0;
else fout << x*(c/d) << " " << y*(c/d) << "\n";
t--;
}
return 0;
}