打不了弟批


私信TA

用户名:WDMoonMoonBird

访问量:33615

签 名:

不想当书法家的程序员不是好厨子

等  级
排  名 27
经  验 15124
参赛次数 122
文章发表 77
年  龄 23
在职情况 学生
学  校 南宁师范大学
专  业 计算机科学与技术

  自我简介:

我爱学习

TA的其他文章

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;
}

详细解题思路请看我的另一篇题解:

信息学奥赛一本通T1616-A 的 B 次方(C++代码)

 

0.0分

1 人评分

  评论区