Created
May 25, 2020 17:12
-
-
Save Remonhasan/550dcbea206ab05f5425455d36fdb1a3 to your computer and use it in GitHub Desktop.
Uva Probelm 10104 using Extended Euclidean Algorithm
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
/* Author; Remon hasan | |
University of Asia Pacific | |
Algorithm : Extended Euclidean [ problem uva 10104 ] | |
*/ | |
#include<bits/stdc++.h> | |
using namespace std; | |
#define ll long long | |
ll eu(ll a, ll b, ll &x, ll &y) | |
{ | |
if(b==0) | |
{ | |
x=1; | |
y=0; | |
return a; | |
} | |
ll x1,y1; | |
ll train=eu(b,a%b,x1,y1); | |
x=y1; | |
y=x1-y1*(a/b); | |
return train; | |
} | |
int main() | |
{ | |
ll a,b; | |
while(scanf("%lld %lld",&a,&b)==2) | |
{ | |
ll x,y,z; | |
z=eu(a,b,x,y); | |
printf("%lld %lld %lld\n",x,y,z); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment