![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 int gcd(int x3,int y3) 2 { 3 int x1 = 1,x2 = 0,y1 = 0,y2 = 1; 4 while(1) 5 { 6 if (y3==1) return y2; 7 int q=x3/y3; 8 int t1=x1-q*y1,t2=x2-q*y2,t3=x3-q*y3; 9 x1 = y1,x2 = y2,x3 = y3; 10 y1 = t1,y2 = t2,y3 = t3; 11 } 12 }
1 int gcd(int x3,int y3) 2 { 3 int x1 = 1,x2 = 0,y1 = 0,y2 = 1; 4 while(1) 5 { 6 if (y3==1) return y2; 7 int q=x3/y3; 8 int t1=x1-q*y1,t2=x2-q*y2,t3=x3-q*y3; 9 x1 = y1,x2 = y2,x3 = y3; 10 y1 = t1,y2 = t2,y3 = t3; 11 } 12 }
转载于:https://www.cnblogs.com/wsruning/p/4674226.html