UVA 10104 Euclid Problem Solution
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd Batch
///Islamic University,Bangladesh
#include<iostream>
using namespace std;
long long egcd(long long a,long long b,long long *x,long long *y)
{
if(b==0)
{
*x=1;
*y=0;
return a;
}
long long x1,y1;
long long gcd=egcd(b,a%b,&x1,&y1);
*y=x1-(a/b)*y1;
*x=y1;
return gcd;
}
int main()
{
long long x,y,a,b,g;
while(cin>>a>>b)
{
g=egcd(a,b,&x,&y);
cout<<x<<" "<<y<<" "<<g<<endl;
}
}
///AH Tonmoy
///Department of CSE,23rd Batch
///Islamic University,Bangladesh
#include<iostream>
using namespace std;
long long egcd(long long a,long long b,long long *x,long long *y)
{
if(b==0)
{
*x=1;
*y=0;
return a;
}
long long x1,y1;
long long gcd=egcd(b,a%b,&x1,&y1);
*y=x1-(a/b)*y1;
*x=y1;
return gcd;
}
int main()
{
long long x,y,a,b,g;
while(cin>>a>>b)
{
g=egcd(a,b,&x,&y);
cout<<x<<" "<<y<<" "<<g<<endl;
}
}
No comments