8
22
2015
0

[BZOJ1008] [HNOI2008] 越狱

我是专业做水题的。

#include<cstdio>

long long n,m;

long long ksm(long long a,long long b){
long long base=a%100003,ans=1;
while(b){
    if(b%2)ans=(ans*base)%100003;
    base=(base*base)%100003;
    b/=2;
}
return ans;
}

int main(){
freopen("1008.in","r",stdin);
freopen("1008.out","w",stdout);
scanf("%lld %lld",&m,&n);
long long df=(ksm(m,n)-m*ksm(m-1,n-1))%100003;
printf("%lld\n",df<0?df+100003:df);
return 0;
}
Category: BZOJ | Tags: oi | Read Count: 435

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com