Cod sursa(job #3293305)
| Utilizator | Data | 11 aprilie 2025 14:03:11 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#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;}
