Cod sursa(job #606067)
| Utilizator | Data | 3 august 2011 12:31:02 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include<fstream.h>
long a,b,c,x,y,d,g,t;
long e(long a,long b)
{if(!b)
return a;
return e(b,a%b);}
void w(long a,long b,long *x,long *y)
{long p,r;
if(!b)
(*x)=1,(*y)=0;
else
w(b,a%b,&p,&r),(*x)=r,(*y)=p-(a/b)*r;}
int main()
{ifstream f("euclid3.in");
ofstream h("euclid3.out");
f>>t;
while(t--)
{f>>a>>b>>c,d=e(a,b);
if(c%d)
h<<"0 0\n";
else
w(a,b,&x,&y),g=c/d,h<<x*g<<" "<<y*g<<"\n";}
return 0;}
