具体看这个大佬的博客真的超级详细
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=10000007;
// n 为底 m为指数
ll fastpower(ll n,ll m){
ll ans=1;
while(m){
if(m&1){//m奇数?
ans=ans*n%mod;
}
m>>=1;//右移,等价于m/=2;
n=n*n%mod;
}
return ans;
}
int main(){
int n,m;
cin>>n>>m;
cout<<fastpower(n,m);
return 0;
}