组合数学:
一共有N^M种方案 不符合的是M*(M-1)*(M-1).... 一共N-1种 也就是说第一个人选择M种 剩下的就是M-1。。 M-1。。。就是相邻的结果。
快速幂模板即可
#include<cstdio>
#include<queue>
#include<iostream>
#include<cmath>
#define LL long long
const LL mod =100003;
using namespace std;
LL N,M,T;
const int maxn=500000+1000;
LL quickpow(LL a,LL b,LL p){// a ^ b % p
LL res=1;
while(b>0){
if(b & 1) res=(res*a)%p;
b>>=1;
a=(a*a)%p;
}
return res;
}
int main()
{
scanf("%lld%lld",&M,&N);
LL ans=1;
ans=ans*quickpow(M,N,mod);
ans-=M*quickpow(M-1,N-1,mod)%mod;
if(ans<0)ans+=mod;
ans%=mod;
cout<<ans<<endl;
return 0;
}