1.
typedef long long ll; ll mod_pow(ll x, ll n, ll mod){ ll res = 1; while(n > 0){ if(n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; }
2.
ll mod_pow(ll x, ll n, ll mod){ if(n == 0) return 1 % mod; ll res = mod_pow(x * x % mod, n/2, mod); if(n & 1) res = res * x % mod; return res; }
3.当 x, n, p都在10^18级别,改为加法
typedef long long LL; LL mod_pow(LL x, LL n, LL mod){ LL ans = 0; while (n > 0){ if (n & 1) ans = (ans + x) % mod; x = x * 2 % p; n >> 1 } return ans; }