typedef long long ll; #include <iostream> using namespace std; ll fast_pwoer(ll base,ll index,ll mod) { ll ans = 1; base %= mod; //指数为循环次数 while (index) { //判断奇偶性 if (index % 2 == 1) { ans = (ans * base) % mod; } base = (base * base) % mod; index /= 2; } return ans; } int main() { int p,m; cin >> p >> m; cout << (fast_pwoer(2,p,m)) << endl; return 0; }
详细解题思路请看我的另一篇题解:
0.0分
1 人评分