BZOJ竟然有这么水的题……
考虑不越狱的状态,显然是
m⋅(m−1)n−1
因为第一个人的信仰随意,后面每个人的信仰都只有n-1种选择
总共有 mn 种方案,那么答案就是 mn−m⋅(m−1)n−1
示例程序:
#include<cstdio>
#define LL long long
const int tt=100003;
LL n,m;
LL power(LL a,LL b){
LL w=a%tt,ans=1;
while (b>0){
if (b&1) (ans*=w)%=tt;
b>>=1;
(w*=w)%=tt;
}
return ans;
}
int main(){
scanf("%lld%lld",&m,&n);
printf("%lld",(power(m,n)-power(m-1,n-1)*m%tt+tt)%tt);
return 0;
}