标签:des style c class blog code
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 312 Accepted Submission(s): 167
1 #include<stdio.h> 2 #define maxn 1000000 3 int n , k ; 4 5 int a[maxn+1]; 6 int r[maxn+1]; 7 void solve() 8 { 9 int i,j; 10 a[0]=a[0]=0; 11 for(i=1,j=0 ;i<=maxn;i++) 12 { 13 a[i]=r[i-1]+1; 14 while(j+1<i && a[j+1]*k<a[i]) 15 j++; 16 r[i]=a[i]+r[j]; 17 if(r[i]>=n) break; 18 } 19 if(i>maxn) 20 { 21 printf("un solvable\n"); 22 return ; 23 } 24 if(a[i]==n) 25 { 26 printf("lose\n"); 27 return ; 28 } 29 for( ; i>=1 ;i--) 30 { 31 if(n==a[i]) 32 { 33 printf("%d\n",n); 34 return ; 35 } 36 else if(n>a[i]) n-=a[i]; 37 } 38 printf("logic error\n"); 39 } 40 int main() 41 { 42 int ca ,cc=0; 43 scanf("%d",&ca); 44 while(ca-->0) 45 { 46 scanf("%d %d",&n,&k); 47 printf("Case %d: ",++ cc); 48 solve(); 49 } 50 return 0; 51 }
HDUOJ--------A simple stone game(尼姆博弈扩展)(2008北京现场赛A题),布布扣,bubuko.com
HDUOJ--------A simple stone game(尼姆博弈扩展)(2008北京现场赛A题)
标签:des style c class blog code
原文地址:http://www.cnblogs.com/gongxijun/p/3751883.html