扩展欧几里德算法求逆元3

 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 }
View Code

 

posted @ 2015-07-24 18:06  相儒以沫  阅读(186)  评论(0编辑  收藏  举报