文章

10

粉丝

224

获赞

12

访问

46.1k

头像
经典快速幂(注意数据类型)
P1017 贵州大学机试题
发布于2022年7月2日 20:39
阅读数 5.0k

#include <bits/stdc++.h>
using namespace std;

int quickPow(long long x, int n)
{
    int res = 1;
    while (n >= 1)
    {
        if (n & 1 == 1)
        {
            res = res * x % 233333;
        }
        n >>= 1;
        x = (x % 233333) * (x % 233333);
    }
    return res;
}

int main()
{
    long long x;
	int n;
    scanf("%lld %d", &x, &n);
    printf("%d\n", quickPow(x, n));
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发