hdu 4155 The Game of 31 博弈论
2013-09-04 14:04
309 查看
给出序列,在剩下的卡中选择,谁先拿到大于31的输,搜一下就可以了!
代码如下:
View Code
代码如下:
#include<cstdio> #include<cstring> char str[25]; int a[7],sum; bool dfs(int m) { if(m>=31) return 0; for(int i=1;i<=6;i++){ if(a[i]&&m+i<=31){ a[i]--; if(!dfs(m+i)){ a[i]++; return 1; } a[i]++; } } return 0; } int main() { while(scanf("%s",str)!=EOF){ int l=strlen(str); for(int i=1;i<=6;i++) a[i]=4; sum=0; for(int i=0;i<l;i++){ sum+=str[i]-'0'; a[str[i]-'0']--; } printf("%s ",str); if(sum>=31){ if(l&1) puts("A"); else puts("B"); continue; } if(dfs(sum)){ if(l&1) puts("B"); else puts("A"); } else{ if(l&1) puts("A"); else puts("B"); } } return 0; }
View Code
相关文章推荐
- HDU 4155 The Game of 31
- 【记忆化搜索】 HDU-4155-The Game of 31
- hdu 4155 The Game of 31
- HDU 4155 The Game of 31 (博弈)
- poj 4155 The Game of 31
- HDOJ 4155 The Game of 31 博弈搜索
- zoj 1827 The Game of 31
- hdu4155 The Game of 31
- ZOJ 1827 The Game of 31
- ZOJ1827_The Game of 31
- HDU 4839 The Game of Coins _(:зゝ∠)_
- The Game of 31 (博弈)
- Codeforces 549C. The Game Of Parity[博弈论]
- HDU 4839 The Game of Coins _(:зゝ∠)_
- 博弈论 —— The Game of Parity ( CodeForces 549C )
- ZOJ1827 HDU4155 The Game of 31,博弈论+爆搜
- GYM 101147 A.The game of Osho(博弈论)
- HDU 4839 The Game of Coins _(:зゝ∠)_
- 【博弈论】【SG函数】【找规律】Gym - 101147A - The game of Osho
- hdu 1595 find the longest of the shortest (Dijkstra+路径处理)