幂次方(暑假每日一题 20)

对任意正整数 N N N,计算 X N   m o d   233333 X^N~mod~233333 XN mod 233333 的值。

输入格式
共一行,两个整数 X X X N N N

输出格式
共一行,一个整数,表示 X N   m o d   233333 X^N~mod~233333 XN mod 233333 的值。

数据范围
1 ≤ X , N ≤ 1 0 9 1≤X,N≤10^9 1X,N109

输入样例:

2 5

输出样例:

32

#include<iostream>

using namespace std;

typedef long long LL;

const int mod = 233333;

int pow(int x, int n){
    
    
    
    int res = 1;
    while(n){
    
    
        if(n & 1) res = ((LL)res * x) % mod;
        x = ((LL)x * x) % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    
    
    
    int x, n;
    cin >> x >> n;
    cout << pow(x, n) << endl;
    
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_46456049/article/details/126259104