# BZOJ 1008 [HNOI2008]越狱

## 1008: [HNOI2008]越狱

Time Limit: 1 Sec  Memory Limit: 162 MB
Submit: 5166  Solved: 2242
[Submit][Status][Discuss]

2 3

6

## HINT

6种状态为(000)(001)(011)(100)(110)(111)

## Source

1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<algorithm>
5 #include<queue>
6 #include<cstring>
7 #define PAU putchar(' ')
8 #define ENT putchar('\n')
9 using namespace std;
10 long long mod=100003;
11 long long pow(long long x,long long y){
12     long long ans=1;for(long long i=y;i;i>>=1,x=x*x%mod)if(i&1)ans=ans*x%mod;return ans%mod;
13 }
15     long long x=0,sig=1;char ch=getchar();
16     while(!isdigit(ch)){if(ch=='-') sig=-1;ch=getchar();}
17     while(isdigit(ch)) x=10*x+ch-'0',ch=getchar();
18     return x*=sig;
19 }
20 inline void write(long long x){
21     if(x==0){putchar('0');return;}if(x<0) putchar('-'),x=-x;
22     int len=0;long long buf[20];while(x) buf[len++]=x%10,x/=10;
23     for(int i=len-1;i>=0;i--) putchar(buf[i]+'0');return;
24 }
25 long long n,m;
26 void init(){
28     long long ans=pow(m,n);
29     ans=(ans+mod-m*pow(m-1,n-1)%mod)%mod;
30     write(ans);
31     return;
32 }
33 void work(){
34     return;
35 }
36 void print(){
37     return;
38 }
39 int main(){
40     init();work();print();return 0;
41 }

posted @ 2015-07-12 14:45  AI_Believer  阅读(113)  评论(0编辑  收藏