zoj 3057 博弈
思路:对于TT来说,如果数量分别为a a b或 a b a,或 b a a的形式,那么TT必赢,因为TT可以使其成为 a a a的形式,那么不论DD 怎么拿,都是TT最后使其成为a a a 的形式,0 0 0也是a a a的形式,故TT胜。同样,存在必败局。如果a,b,c是先手的必败局,那么将其中某个数加k,或将其中某两个数同时加k,那么就成了先手的必胜局。
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pb push_back
#define mp make_pair
#define Maxn 100010
#define Maxm 200010
#define LL __int64
#define Abs(x) ((x)>0?(x):(-x))
#define lson(x) (x<<1)
#define rson(x) (x<<1|1)
#define inf 100000
#define lowbit(x) (x&(-x))
#define clr(x,y) memset(x,y,sizeof(x))
#define Mod 1000000007
using namespace std;
bool dp[][][];
void init()
{
int i,j,k,r;
dp[][][]=;
for(i=;i<=;i++){
for(j=;j<=;j++){
for(k=;k<=;k++){
if((i!=j||i!=k||j!=k)&&(i==j||i==k||j==k)){
dp[i][j][k]=;
continue;
}
if(!dp[i][j][k]){
for(r=;r<=;r++){
if(i+r<=)
dp[i+r][j][k]=;
if(j+r<=)
dp[i][j+r][k]=;
if(k+r<=)
dp[i][j][k+r]=;
if(i+r<=&&j+r<=)
dp[i+r][j+r][k]=;
if(i+r<=&&k+r<=)
dp[i+r][j][k+r]=;
if(j+r<=&&k+r<=)
dp[i][j+r][k+r]=;
}
}
}
}
}
}
int main()
{
int a,b,c;
init();
while(scanf("%d%d%d",&a,&b,&c)!=EOF){
printf("%d\n",dp[a][b][c]);
}
return ;
}
zoj 3057 博弈的更多相关文章
- 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 Beans Game(DP博弈)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 有豆类三个桩.TT和DD挑选任意数量的豆子从任何两堆轮流任何桩或相同 ...
- 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 ...
- ZOJ 3057 Beans Game 博弈论 sg函数
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 典型的sg函数,数据范围卡得真好啊 代码 #include<c ...
- zoj 3882 博弈 *
看了半天约数居然包括1,水了 #include<cstdio> #include<iostream> #include<algorithm> #include< ...
- zoj 3057 Beans Game 博弈论
思路:三维DP,刚开始用记忆化搜索,MLE…… 后来改为直接预处理所有的情况. 总之就是必败态的后继是必胜态!!! 代码如下: #include<iostream> #include< ...
- ZOJ 3666 博弈 SG函数
SG函数: 对于任意状态,定义SG(x)=mex(S),其中S是x的后继状态的SG函数值集合,mex(S)表示不再S内的最小非负整数 SG(X)=0当且仅当x为必败态. 解: 构造一个有向无环图(树) ...
- ZOJ 1893 A Multiplication Game 【简单博弈】
感觉ZJU上有不少博弈的题目. 这道题目还是比较好理解的,题目大概意思是:两人轮流乘一个2-9的数,从1开始乘,求谁的乘积先大于N. 还是寻找必败点必胜点,不过在这个题目里转换成了寻找必败区间必胜区间 ...
- ZOJ 3529 A Game Between Alice and Bob 博弈好题
A Game Between Alice and Bob Time Limit: 5 Seconds Memory Limit: 262144 KB Alice and Bob play t ...
随机推荐
- Use jQuery to hide a DIV when the user clicks outside of it
http://stackoverflow.com/questions/1403615/use-jquery-to-hide-a-div-when-the-user-clicks-outside-of- ...
- uva140 - Bandwidth
Bandwidth Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an orderi ...
- 可拖拽GridView代码解析
本片学习笔记是对eoe网上一个项目代码的解读.详细项目作者的博客例如以下:http://blog.csdn.net/vipzjyno1/article/details/26514543.项目源代码下载 ...
- jQuery Mobile 手动显示ajax加载器,提示加载中...
在使用jQuery Mobile开发时,有时候我们需要在请求ajax期间,显示加载提示框(例如:一个旋转图片+一个提示:加载中...).这个时候,我们可以手动显示jQuery Mobile的加载器,大 ...
- Beautyacticle
Original: https://github.com/rizhilee/Beautyacticle Backup: https://github.com/eltld/Beautyacticle
- Circle-Progress-View
https://github.com/jakob-grabner/Circle-Progress-View
- vs开发工具之--自动生成注释
GhostDoc是Visual Studio的一个免费插件,轻松一个快捷键CTRL+SHIFT+D就能够帮助自动生成注释 下载地址:http://submain.com/download/ghostd ...
- 剑指 offer set 2 从头到尾打印链表
总结 1. 书中给出的最终解法是递归或用堆栈模拟递归. 之前我一直不清楚是否还有更优雅的做法, 看样是没了
- How does a relational database work
http://blog.jobbole.com/100349/ http://coding-geek.com/how-databases-work/
- close和shutdown函数的区别
close函数首先是将传入的socket句柄引用数减1(因为fork进程时会导致socket句柄被多个进程引用),待到引用数等于0的时候,close才会真正关闭连接. shutdown函数是立刻关闭连 ...