Pagini recente » Cod sursa (job #806994) | Cod sursa (job #1011099) | Borderou de evaluare (job #496711) | Cod sursa (job #1193144) | Cod sursa (job #163160)
Cod sursa(job #163160)
#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;
}