ZOJ 3057 Beans Game 【DP+博弈】
来源:互联网 发布:怎么安装visio软件 编辑:程序博客网 时间:2024/05/29 02:03
Beans Game
Time Limit: 5 Seconds Memory Limit: 32768 KB
There are three piles of beans. TT and DD pick any number of beans from any pile or the same number from any two piles by turns. Who get the last bean will win. TT and DD are very clever.
Input
Each test case contains of a single line containing 3 integers a b c, indicating the numbers of beans of these piles. It is assumed that 0 <= a,b,c <= 300 and a + b + c > 0.
Output
For each test case, output 1 if TT will win, ouput 0 if DD will win.
Sample Input
1 0 0
1 1 1
2 3 6
Sample Output
1
0
0
题意:
三维数组分别表示,取三个物品的数量。1.那么之前出现过某两物品数相同,且另一物品数小于当前第三物品数的状态为必胜态,2.如果一物品数相同,且另两物品数大于前面的另外两个物品数,且差相同,则为必胜态,不是这两种必胜态,则为必败态。
正推的效率远不及倒推的效率。
记忆化搜索会炸内存,甚至int都不行,必须用bool。
#include<iostream> #include<cstdio> #include<ctime> #include<cstring> #include<cmath> #include<algorithm> #include<cstdlib> #include<vector> #define C 240 #define TIME 10 #define inf 1<<25 #define LL long long using namespace std; bool dp[301][301][301]={0}; void Init(){ for(int i=0;i<=300;i++){ for(int j=0;j<=300;j++){ for(int k=0;k<=300;k++){ if(!dp[i][j][k]){ for(int r=1;r+i<=300;r++) dp[i+r][j][k]=1; for(int r=1;r+j<=300;r++) dp[i][j+r][k]=1; for(int r=1;r+k<=300;r++) dp[i][j][k+r]=1; for(int r=1;r+j<=300&&r+i<=300;r++) dp[i+r][j+r][k]=1; for(int r=1;r+j<=300&&r+k<=300;r++) dp[i][j+r][k+r]=1; for(int r=1;r+k<=300&&r+i<=300;r++) dp[i+r][j][k+r]=1; } } } } } int main(){ int a,b,c; Init(); while(cin>>a>>b>>c) cout<<dp[a][b][c]<<endl; return 0; }
- 博弈---ZOJ 3057 Beans Game(DP博弈)
- ZOJ 3057 Beans Game(博弈DP)
- Beans Game(博弈 | | DP)zoj 3057
- ZOJ 3057 Beans Game 博弈DP
- ZOJ 3057 Beans Game 【DP+博弈】
- ZOJ 3057 Beans Game (博弈入门)
- zoj 3057Beans Game
- zoj3057 Beans Game---三维DP 博弈
- zoj3057 Beans Game---三维DP 博弈
- ZOJ 3057 Beans Game题解
- ZOJ 3057 组合博弈 DP
- zoj 2290 GAME 博弈
- [博弈][DP]DLUTOJ1328: Bricks Game
- 【SPOJ-MGAME1】Game【博弈DP】
- 【ZOJ 1913】Euclid's Game(博弈)
- ZOJ-1039 Number Game(SG博弈)
- ZOJ 1024 Calendar Game (DP)
- poj1678 I Love this Game!---dp博弈
- 1674:前10名
- HYSBZ
- 分享在工作生活中更好地运用思维导图使用攻略
- 关于Java中的进程和线程的理解
- oracle日期与字符串的互相转换SQL语句
- ZOJ 3057 Beans Game 【DP+博弈】
- angular,使用directive实现,将input的数字保留两位小数,不足两位补0.
- Android键盘显示隐藏优化
- leetcode-50-pow
- JAVA并发与多线程 面试题目
- 专访iDST华先胜:城市大脑_对城市的全量、实时认知和搜索
- PlatformIO IDE搭建统一的物联网嵌入式开发环境
- .net 调用webservice接口
- ssh免密码登录