It's not very clear in the textbook about this section.
Part of the content is referenced from: http://www.cnblogs.com/frog112111/archive/2012/08/19/2646012.html
Extended Euclidean algorithm
Basic algorithm: For a non-negative integer A,B,GCD (A, B) that is not exactly 0, the greatest common divisor of A/b is bound to have an integer pair of x, Y, which makes gcd (A, b) =ax+by.
The application of the extended Euclidean algorithm mainly has the following three aspects:
(1) solving indefinite equation;
(2) solving the linear linear equation (congruence);
(3) The inverse element of the solution module;
(1):
Set A,b,c to any integer, G=GCD (A, b), the equation ax+by=g a set of solutions (X0,Y0), when C is a multiple of G, ax+by=c a group of solutions for (p0,q0) = (x0*c/g,y0*c/g), the other solution of the equation is (pi,qi) = (P0 + b/g * t,q0-a/g*t) where T is an arbitrary value, and when C is not a multiple of G, there is no solution
void meuclid (int a, int b, int &d, int &x, int &if(b==0) {d=a;x=1; y=0; returnElse {meuclid (b,a%b,d,y,x); Y-=x* (A/b); }}
View Code
Expand Euclidean algorithm, point on a straight line