Created
March 16, 2015 18:20
-
-
Save shohan4556/e47153446c58637240d2 to your computer and use it in GitHub Desktop.
UVA -- 10104 solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int extends_euclid(int a,int b,int &x,int &y); | |
int main() | |
{ | |
int a,b,x,y; | |
int d; | |
while(scanf("%d %d",&a,&b)==2){ | |
d=extends_euclid(a,b,x,y); | |
if (a == b) { | |
x = 0; | |
y = 1; | |
} | |
printf("%d %d %d\n",x,y,d); | |
} | |
return 0; | |
} | |
int extends_euclid(int a,int b,int &x,int &y) | |
{ | |
int x1,y1,d; | |
if(a==0){ | |
x=0; | |
y=1; | |
return b; | |
} | |
d=extends_euclid(b%a,a,x1,y1); | |
x=y1-(b/a)*x1; | |
y=x1; | |
return d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment