Pagini recente » Cod sursa (job #2592737) | Cod sursa (job #208591) | Clasament the_wild_west | Cod sursa (job #1816658) | Cod sursa (job #1459279)
#include <iostream>
#include <fstream>
#define fin "euclid3.in"
#define fou "euclid3.out"
using namespace std;
ifstream t1(fin);
ofstream t2(fou);
int a,b,c,x,y;
int euclidextins(int a, int b,int &x,int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
int x0,y0,d;
d=euclidextins(b, a % b,x0,y0);
x=y0;
y=x0-b*y0;
return d;
}
}
int main()
{
int n,i,x,y,d;
t1 >> n;
for (i = 1; i <= n;i++)
{
t1>>a>>b>>c;
d=euclidextins(a,b,x,y);
if(c%d) t2<<"0 0"<<'\n';
else t2<<x*(c/d)<<' '<<y*(c/d)<<'\n';
}
t1.close();
t2.close();
return 0;
}