Pagini recente » Cod sursa (job #315350) | Cod sursa (job #992523) | Cod sursa (job #2892654) | Cod sursa (job #2442507) | Cod sursa (job #588151)
Cod sursa(job #588151)
#include<fstream.h>
long a,b,c,x,y,d,g,e;
int t;
long euclid1(long a,long b)
{if(b==0)
return a;
return euclid1(b,a%b);}
void euclid2(long a,long b,long *x,long *y)
{long x0,y0;
if(b==0)
(*x)=1,(*y)=0;
else
euclid2(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=euclid1(a,b);
if(c%d!=0)
h<<"0 0\n";
else
euclid2(a,b,&x,&y),g=c/d,h<<x*g<<" "<<y*g<<"\n";}
f.close();
h.close();
return 0;}