Pagini recente » Cod sursa (job #3291488) | Cod sursa (job #3291480) | Cod sursa (job #3291435) | Cod sursa (job #3293305)
#include<fstream.h>
long a,b,c,x,y,d,g,t;
long e1(long a,long b)
{if(b==0)
return a;
return e1(b,a%b);}
void e2(long a,long b,long *x,long *y)
{long x0,y0;
if(b==0)
(*x)=1,(*y)=0;
else
e2(b,a%b,&x0,&y0),(*x)=y0,(*y)=x0-(a/b)*y0;}
int main()
{ifstream f("euclid3.in");
ofstream h("euclid3.out");
f>>t;
while(t--)
{f>>a>>b>>c;
d=e1(a,b);
if(c%d!=0)
h<<"0 0\n";
else
e2(a,b,&x,&y),g=c/d,h<<x*g<<" "<<y*g<<"\n";}
f.close();
h.close();
return 0;}