Cod sursa(job #695168)
| Utilizator | Data | 28 februarie 2012 10:53:54 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <cstdio>
long long x,y,d;
void eucl(long long a,long long b){
if(!b){
x=1;
y=0;
d=a;
return;
}
eucl(b,a%b);
int tmp=y;
y=x-(a/b)*y;
x=tmp;
}
int main(){
freopen("euclid3.in","r",stdin);
freopen("euclid3.out","w",stdout);
long long t,a,b,c;
scanf("%lld",&t);
while(t--){
scanf("%lld%lld%lld",&a,&b,&c);
eucl(a,b);
if(c%d)
printf("0 0\n");
else
printf("%lld %lld\n",x*c/d,y*c/d);
}
return 0;
}
