Cod sursa(job #237243)
| Utilizator | Data | 29 decembrie 2008 13:15:22 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
# include <stdio.h>
long A,B,C;
void euclid(long a, long b, long &d, long &x, long &y)
{
long x0, y0;
if (b==0) {
d=a;
x=1;
y=0;
} else {
euclid(b,a%b,d,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
long main(){
long d,x,y;
int i,T;
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d",&T);
for (i=1;i<=T;i++){
scanf("%ld %ld %ld",&A,&B,&C);
euclid(A,B,d,x,y);
if (C%d==1) printf("0 0\n");
else printf("%ld %ld\n", x*(C/d),y*(C/d));
}
return 0;
}