zoj 3057 Beans Game 博弈论
思路:三维DP,刚开始用记忆化搜索,MLE……
后来改为直接预处理所有的情况。
总之就是必败态的后继是必胜态!!!
代码如下:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#define ll long long
#define M 302
#define inf 1e10
#define mod 1000000007
using namespace std;
bool dp[M][M][M];
int main()
{
int a,b,c,t;
memset(dp,,sizeof(dp));
for(int i=;i<=;i++)
for(int j=;j<=;j++)
for(int k=;k<=;k++){
if(!dp[i][j][k]){
for(t=;t+i<=;t++)
dp[i+t][j][k]=;
for(t=;t+j<=;t++)
dp[i][j+t][k]=;
for(t=;t+k<=;t++)
dp[i][j][k+t]=;
for(t=;t+i<=&&t+j<=;t++)
dp[i+t][j+t][k]=;
for(t=;t+i<=&&t+k<=;t++)
dp[i+t][j][k+t]=;
for(t=;t+j<=&&t+k<=;t++)
dp[i][j+t][k+t]=;
}
}
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
printf("%d\n",dp[a][b][c]);
}
return ;
}
zoj 3057 Beans Game 博弈论的更多相关文章
- ZOJ 3057 Beans Game 博弈论 sg函数
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 典型的sg函数,数据范围卡得真好啊 代码 #include<c ...
- 博弈---ZOJ 3057 Beans Game(DP博弈)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 有豆类三个桩.TT和DD挑选任意数量的豆子从任何两堆轮流任何桩或相同 ...
- Beans Game(博弈 | | DP)zoj 3057
Beans Game Time Limit: 5 Seconds Memory Limit: 32768 KB There are three piles of beans. TT and DD pi ...
- ZOJ - 3057 D - Beans Game(三堆威佐夫博弈)
Beans Game Time Limit: 5 Seconds Memory Limit: 32768 KB There are three piles of beans. TT and DD pi ...
- hdu 1404/zoj 2725 Digital Deletions 博弈论
暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<c ...
- zoj 2686 Cycle Game 博弈论
其实规律很好找的,当从某点开始,向某一边找出非0的个数,为奇数时必胜. 代码如下: #include<iostream> #include<cstdio> using name ...
- zoj 3057 博弈
思路:对于TT来说,如果数量分别为a a b或 a b a,或 b a a的形式,那么TT必赢,因为TT可以使其成为 a a a的形式,那么不论DD 怎么拿,都是TT最后使其成为a a a 的形式,0 ...
- SG函数和SG定理【详解】
在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜点和必败点的概念: P点:必败点,换而言之,就是谁处于此位置,则在双方操作正确的情况下必败. N点:必胜点 ...
- (转载)--SG函数和SG定理【详解】
在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜点和必败点的概念: P点:必败点,换而言之,就是谁处于此位置,则在双方操作正确的情况下必败. N点:必胜点 ...
随机推荐
- poj 1459 Power Network
题目连接 http://poj.org/problem?id=1459 Power Network Description A power network consists of nodes (pow ...
- Spring Roo
Spring Roo 是SpringSource新的开放源码技术,该技术主要面向企业中的Java开发者,使之更富有成效和愉快的进行开发工作,而不会牺牲工程完整或灵活性.无论你是一个新的Java开发人员 ...
- CPU 材料学才是最顶级的学科
cpu的物理组成3部分:逻辑部件.寄存器.控制部件 CPU具有以下4个方面的基本功能:数据通信,资源共享,分布式处理,提供系统可靠性 cpu处理4过程:提取.解码.执行.写回 http://baike ...
- 如何用nodejs写入mysql 的blob格式的数据
So, if the array length equals 4, then the size of blob data in mysql DB must be 4 bytes. And it wor ...
- flask环境配置
1.首先要看装python环境,最好是python 2.7版本的: 2.安装easy_install,至今也不确定这个东西是怎么装的,我先下载了一个ez_setup,用命令“python ez_set ...
- NewRelicAgent(CustomAnalyticEvent.cxx.o), building for iOS simulator, but linking in object file built for OSX, for architecture x8(botched)
昨天遇到一个问题,在项目swift1.2适配swift2.0的过程中,修改完毕之后,运行报错如下: /Pods/NewRelicAgent/NewRelic_iOS_Agent_5.1.0/NewRe ...
- Bootstrap入门四:代码
1.内联代码 code: 通过 <code> 标签包裹内联样式的代码片段.灰色背景.灰色边框和红色字体. For example, <code><section>& ...
- 【转】#ifdef _DEBUG用法小结
原文地址:http://blog.csdn.net/shijizhisheng/article/details/1908054 1 #ifdef _DEBUG virtual void AssertV ...
- vmware workstation 10.0
2013.9.3 vmware workstation 10.0 build 1295980新增功能– 可以将windows 8.1物理pc转变为虚拟机:unity模式增强,与windows 8.1 ...
- 【BZOJ】【1912】【APIO2010】patrol巡逻
树形DP 说是树形DP,其实就是求树的最长链嘛…… K=1的时候明显是将树的最长链的两端连起来最优. 但是K=2的时候怎么搞? 考虑第一次找完树的最长链以后的影响:第一次找过的边如果第二次再走,对答案 ...