Cod sursa(job #163160)
| Utilizator | Data | 21 martie 2008 15:55:54 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <stdio.h>
long a, b;
long cmmdc(long a, long b, int&x, int &y){
if(b==0){
x=1; y=0;
return a;
}
int x1, y1, d;
d=cmmdc(b, a%b, x1, y1);
x=x1;
y=x1-(a/b)*y1;
printf("%d %d\n", x, y);
return cmmdc(b, a%b, x1, y1);
}
int main()
{
int x, y;
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%ld %ld", &a, &b);
printf("%ld\n ", cmmdc(a, b, x, y));
return 0;
}
