Pagini recente » Cod sursa (job #1762873) | Cod sursa (job #2144750) | Cod sursa (job #2831285) | Cod sursa (job #1910415) | Cod sursa (job #1372139)
#include <iostream>
#include <fstream>
using namespace std;
int a, b, c, x, y, d, n, i, ok;
int euclid3(int a, int b,int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
int x0, y0;
int d=euclid3(b, a%b, x0, y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
fin>>n;
for(i=1; i<=n; i++)
{
fin>>a>>b>>c;
d=euclid3(a, b, x, y);
if(c%d==0)
{
ok=c/d;
fout<<x*ok<<" "<<y*ok<<"\n";
}
else fout<<"0 0\n";
}
return 0;
}