天天看點

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

對任意正整數 ,計算

輸入格式

共一行,兩個整數 和 。

輸出格式

共一行,一個整數,表示

資料範圍

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