📅  最后修改于: 2022-03-11 14:59:02.898000             🧑  作者: Mango
int modPow(int base, int exp, int n) {
base = base%n;
if (exp == 0)
return 1;
else if (exp == 1)
return base;
else if (exp%2 == 0)
return modPow(base*base%n, exp/2, n);
else
return base*modPow(base, exp-1, n)%n;