#include "stdio.h" int n, m, mod; long long quick_power(long long x, long long y){ long long sum = 1; while(y){ if(y & 1){//相当于 y % 2 == 1; sum = sum * x % mod; } y >>= 1;//相当于 y /= 2; x = x * x % mod; } return sum; } int main() { n = 2, m = 1000000000, mod = 1000; printf("%lld\n",quick_power(n,m)); return 0; }
原文:https://www.cnblogs.com/rongrongrong/p/14668278.html