组合数学
共有(m^n)中状态,会越狱的有(m*(m-1)^(n-1))种方案,用快速幂
#include<cstdio>
#define ll long long
using namespace std;
const int mod=100003;
ll pow(ll a,ll b){
ll c=1,d=a%mod;
while(b>0){
if(b&1)
c=(c%mod*d%mod)%mod;
b>>=1;
d=(d%mod*d%mod)%mod;
}
return c;
}
int main(){
ll m,n;
scanf("%lld%lld",&m,&n);
printf("%lld",(pow(m%mod,n)-pow((m-1)%mod,n-1)*m%mod)%mod);//这里要注意加上mod再模,因为可能m^n%P以后小于后者
return 0;
}