BZOJ 1008:[HNOI2008]越狱

傻逼题,然后n,m写反了WA了一发。。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
typedef long long LL;
using namespace std;
const LL mod=100003;
LL n,m,ans,tp;
LL ksm(LL a,LL b) {
    LL base=a,res=1;
    while(b) {
        if(b&1) (res*=base)%=mod;
        (base*=base)%=mod;
        b>>=1;
    }
    return res;
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%lld%lld",&m,&n);
    ans=ksm(m,n);
    tp=(m*ksm(m-1,n-1))%mod;
    ((ans-=tp)+=mod)%=mod;
    printf("%lld\n",ans);
    return 0;
}
View Code

 

posted @ 2017-09-16 17:03  啊宸  阅读(95)  评论(2编辑  收藏  举报