快速幂,a的b次方;
LL sm(LL a, LL b) { LL ans = 1; a = a%mod; while (b > 0) { if (b % 2 == 1) ans = (ans*a) % mod; b = b / 2; a = (a*a) % mod; } return ans%mod; }
快速幂,a的b次方;
LL sm(LL a, LL b) { LL ans = 1; a = a%mod; while (b > 0) { if (b % 2 == 1) ans = (ans*a) % mod; b = b / 2; a = (a*a) % mod; } return ans%mod; }