求x的y次幂

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int Max=100000;
LL fun(LL x,LL n)
{
    LL res=1;
    while(n>0)
    {
        if(n & 1)
            res=(res*x)%Max;
        x=(x*x)%Max;
        n >>= 1;
    }
    return res;
}
int main()
{
    cout<<fun(245335435,11213456123)<<endl;
    return 0;
}

你可能感兴趣的:(求x的y次幂)