给出序列,在剩下的卡中选择,谁先拿到大于31的输,搜一下就可以了!

代码如下:

 #include<cstdio>
#include<cstring>
char str[];
int a[],sum;
bool dfs(int m)
{
if(m>=) return ;
for(int i=;i<=;i++){
if(a[i]&&m+i<=){
a[i]--;
if(!dfs(m+i)){
a[i]++;
return ;
}
a[i]++;
}
}
return ;
}
int main()
{
while(scanf("%s",str)!=EOF){
int l=strlen(str);
for(int i=;i<=;i++) a[i]=;
sum=;
for(int i=;i<l;i++){
sum+=str[i]-'';
a[str[i]-'']--;
}
printf("%s ",str);
if(sum>=){
if(l&) puts("A");
else puts("B");
continue;
}
if(dfs(sum)){
if(l&) puts("B");
else puts("A");
}
else{
if(l&) puts("A");
else puts("B");
}
}
return ;
}

hdu 4155 The Game of 31 博弈论的更多相关文章

  1. HDU 2516 取石子游戏 (博弈论)

    取石子游戏 Problem Description 1堆石子有n个,两人轮流取.先取者第1次能够取随意多个,但不能所有取完.以后每次取的石子数不能超过上次取子数的2倍.取完者胜.先取者负输出" ...

  2. hdu 4753 Fishhead’s Little Game 博弈论+记忆化搜索

    思路:状态最多有2^12,采用记忆化搜索!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm& ...

  3. hdu 1404/zoj 2725 Digital Deletions 博弈论

    暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<c ...

  4. hdu 1538 A Puzzle for Pirates 博弈论

    很经典的问题,思路转载自http://blog.csdn.net/ACM_cxlove?viewmode=contents 题目:这是一个经典问题,有n个海盗,分m块金子,其中他们会按一定的顺序提出自 ...

  5. hdu 4672 Present Day, Present Time 博弈论

    看了解题报告才知道怎么做!! 题意:有 N 堆石子和 M 个石子回收站,每回合操作的人可以选择一堆石子,从中拿出一些 放到石子回收站里(可以放进多个回收站,每个回收站可以使用无数次),但每个石子回收站 ...

  6. hdu 3032 Nim or not Nim? 博弈论

     这题是Lasker’s Nim. Clearly the Sprague-Grundy function for the one-pile game satisfies g(0) = 0 and g( ...

  7. hdu 1760 A New Tetris Game 博弈论

    找sg值,可以选择暴力,也可以利用sg值的特点简化. 暴力就跟取石子一样,没什么差别,DFS搞定.把矩阵看成一个字符串,字符串就是一个状态. 其实我们也可以不暴力求sg值,因为只要当前状态能到达一个s ...

  8. HDU.1848.Fibonacci again and again(博弈论 Nim)

    题目链接 //求三堆石子的SG函数,异或起来就是整个游戏的SG值 #include <cstdio> #include <cstring> const int N=1005; ...

  9. hdu 1525 Euclid's Game【 博弈论】

    Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtra ...

随机推荐

  1. hdu 2034 人见人爱A-B

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目, ...

  2. [转]Not enough free disk space on disk '/boot'

    Not enough free disk space on disk '/boot' http://my.oschina.net/u/947673/blog/277224 # 解决 出现此情况是因为你 ...

  3. Oracle之sql追踪

    select * from v$sqlarea t where t.sql_text like '%_070%' order by t.LAST_ACTIVE_TIME desc SELECT * F ...

  4. 表格实现hao123

    一.表格实现hao123用到的标签元素 1.[width][bordercolor][cellpadding][rules="none"隐藏表格内线框][border] 例如: & ...

  5. svn版本控制器在vs2013中的使用

      下面记录常用的几种用法:   a) SVN检出 将SVN服务端所保存的数据下载到个人工作平台. 组长上传初始项目后,各组员可以到服务器上检出项目 1. 打开Visual Studio 2010-& ...

  6. struts1 和 struts2中Action什么时候实例化

    精帖1:http://blog.csdn.net/lfsf802/article/details/7277013 精帖1:http://blog.csdn.net/wmj2003/article/de ...

  7. windows下将多个文件里面的内容合并成一个一个文件

    如题:例如有多个章节的小说,现在要把他们合并成一个txt文件. 利用windows自带cmd工具: 一.拷贝合并1.将你的txt文档按照顺序分别命名为01.txt 02.txt 03.txt……2.将 ...

  8. Ext通过后台校验字段是否重复

    话不多说,直接上代码: handlerRybh : function(textField) { Ext.Ajax.request({// ajax请求的方法 url : 'userManage/per ...

  9. bzoj 2141 线段树套平衡树

    用树套树来解决这个问题,存储每个节点的数值是多少,然后交换 对于答案的变更可以讨论下,假设交换的是x,y位置的数x<=y 如果x=y || high[x]=high[y]则对答案没有影响 如果h ...

  10. STMPClient 发送邮件显示 不允许使用邮件名称.

      在.net 2.0,3.5, 针对某些邮箱(还不清楚是什么样的邮件) , 使用微软自带的DLL发送邮件会提示不允许使用邮件名称 .... 使用Jmail可以发送.     解决方案:     1. ...