Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. void Gcd(int64 a, int64 b, int64* res) {
  2.     int64 U[3] = { a, 1, 0 }, V[3] = { b, 0, 1 }, T[3], q, temp;
  3.     while (V[0] != 0)
  4.     {
  5.         q = U[0] / V[0];
  6.         T[0] = U[0] % V[0]; T[1] = U[1] - q*V[1]; T[2] = U[2] - q*V[2];
  7.         U[0] = V[0]; U[1] = V[1]; U[2] = V[2];
  8.         V[0] = T[0]; V[1] = T[1]; V[2] = T[2];
  9.     }  
  10.     res[0] = U[0]; res[1] = U[1]; res[2] = U[2];
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement