Cod sursa(job #656887)
| Utilizator | Data | 5 ianuarie 2012 14:12:30 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include<fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
long t,a,b,c,d,x,y;
long euclid ( long a, long b)
{
long cx,cy,rez;
if ( b==0 )
{
x=1;
y=0;
return a;
}
rez=euclid ( b,a%b );
cx=x;
cy=y;
x=cy;
y=cx-(a/b)*cy;
return rez;
}
int main()
{
in>>t;
for ( ; t; t-- )
{
in>>a>>b>>c;
d=euclid(a,b);
if ( c%d==0 )
out<<x*c/d<<" "<<y*c/d<<"\n";
else
out<<"0 0\n";
}
}
