思路:dp[i][j]:第i个人时还剩j个石头。

当j为0时,有必胜为1;

后继中有必败态的为必胜态!!记忆化搜索下就可以了!

代码如下:

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#define inf 1e9
using namespace std;
int dp[][],n,a[];
int dfs(int d,int s)
{
if(dp[d][s]!=-) return dp[d][s];
if(s==) return dp[d][s]=;
dp[d][s]=;
for(int i=;i<=a[d]&&i<=s;i++)
if(!dfs((d+)%(*n),s-i))
dp[d][s]=;
return dp[d][s];
}
int main()
{
int i,j,q,k,t,s;
while(scanf("%d",&n)&&n){
scanf("%d",&s);
memset(dp,-,sizeof(dp));
for(i=;i<*n;i++) scanf("%d",&a[i]);
printf("%d\n",dfs(,s));
}
return ;
}

最新文章

  1. 网页JQ基础之jq-隐藏以及显示特效
  2. sqlite3使用(一)
  3. Windows下mysql自动备份的最佳方案
  4. 杭JS
  5. 51中的C语言数据类型
  6. Android单元测试: 首先,从是什么开始
  7. myEclipse勿删文件怎么恢复
  8. Java Persistence with MyBatis 3(中国版) 第五章 与Spring集成
  9. SD卡读写扇区注意事项(转)
  10. js document
  11. Html +++++css总结
  12. mpvue——另类支持v-html
  13. Python——scapy模块实现tcp探测目标服务器路由轨迹
  14. 与虚拟机连接出现ora-12514错误解决方法
  15. POJ2279杨氏矩阵+钩子定理
  16. R中执行if else报错:unexpected &#39;else&#39; in &quot;else&quot;
  17. 【BZOJ5334】数学计算(线段树)
  18. .NET类库
  19. 单片机关键字sfr和sbit的理解
  20. If you want the rainbow, you have to deal with the rain.

热门文章

  1. sharepoint 2010 切换域
  2. 基础语法 swift
  3. JAVA素数分解
  4. P1951: [Sdoi2010]古代猪文
  5. Linux Shel高级技巧(目录)
  6. C++中栈的出栈,入栈规则:A,B,C,D,E
  7. ERP系统实施与企业内部控制管理实践
  8. 团队开发NABC特点
  9. c编程之排序
  10. Java 7 中 NIO.2 的使用——第二节 元数据文件的属性