ZOJ1827 HDU4155 The Game of 31,博弈论+爆搜
来源:互联网 发布:淘宝客链接转换工具apk 编辑:程序博客网 时间:2024/05/22 05:10
爆搜吧,数据量不大,没必要用记忆化
/******************************************************************************* # Author : Neo Fung # Email : neosfung@gmail.com # Last modified: 2012-06-21 17:50 # Filename: ZOJ1827 HDU4155 The Game of 31.cpp # Description : ******************************************************************************/#ifdef _MSC_VER#define DEBUG#define _CRT_SECURE_NO_DEPRECATE#endif#include <fstream>#include <stdio.h>#include <iostream>#include <string.h>#include <string>#include <limits.h>#include <algorithm>#include <math.h>#include <numeric>#include <functional>#include <ctype.h>using namespace std;const int kMAX=10010;const double kEPS=10E-6;int num[7];bool dfs(const int &sum)//是否必败点{if(sum>=31)return true;//如果到达本节点时sum大于等于31,则此时加任何数字都是输的,可知本节点是必败点for(int i=1;i<=6;++i)if(num[i] && sum+i<=31){--num[i];if(dfs(sum+i))//找到一个后续节点是必败点,则本节点是必胜点{++num[i];return false;}++num[i];}return true;//找不到任何后续节点是必败点,则本节点也是比败点}int main(void){#ifdef DEBUG freopen("../stdin.txt","r",stdin); freopen("../stdout.txt","w",stdout); #endif int n;char str[kMAX]; while(~scanf("%s",str)) {int len=strlen(str);for(int i=1;i<=6;++i)num[i]=4;int sum=0;for(size_t i=0;i<len;++i){--num[str[i]-'0'];sum+=str[i]-'0';}printf("%s ",str);if(dfs(sum)){if(len&1)printf("A\n");elseprintf("B\n");} else { if(len&1) printf("B\n"); else printf("A\n"); } } return 0;}
- ZOJ1827 HDU4155 The Game of 31,博弈论+爆搜
- hdu4155 The Game of 31
- hdu4155 The Game of 31------sg dfs
- Hdu4155The Game of 31(DFS+博弈论)
- 博弈论 —— The Game of Parity ( CodeForces 549C )
- GYM 101147 A.The game of Osho(博弈论)
- The Game of 31 (博弈)
- Problem H. Game with the Stones 博弈论
- ZOJ 1827 The Game of 31
- zoj 1827 The Game of 31
- hdu 4155 The Game of 31
- 博弈论---Game!
- The rule of game
- Game of the Rows
- Game of the Rows
- uva 12530 Game of Tiles (二分图完美匹配+博弈论)
- UVA 10891 Game of Sum (博弈论 + 区间dp)
- GYM 101128 G.Game of Cards(博弈论)
- Hibernate DAO中的几个方法
- 什么时候使用静态方法
- 在Windows 7中,十步实现单个用户组策略配置
- jsp完整图片上传
- Chrome插件Math Anywhere,渲染有Latex的网页
- ZOJ1827 HDU4155 The Game of 31,博弈论+爆搜
- 纯真IP数据库格式详解
- 关于WES7的系统还原与恢复
- 成功管理组织转型的三个关键要素
- socket通信代码练习——每天进步一点点
- Linux Vim插件配置
- Linux基本命令df和linux中df命令参数介绍
- 超敏感机械手指 精确性超越人类
- Spring bean作用域