返回 a^b mod c 的值
1 int Mont(int a, int b, int c) 2 { 3 int t = 1; 4 a %= c; 5 while (b) { 6 if (b & 1) t = t * a % c; 7 b >>= 1, a = a * a % c; 8 } 9 return t; 10 }
返回 a^b mod c 的值
1 int Mont(int a, int b, int c) 2 { 3 int t = 1; 4 a %= c; 5 while (b) { 6 if (b & 1) t = t * a % c; 7 b >>= 1, a = a * a % c; 8 } 9 return t; 10 }