FOJ 1523 A Version of Nim
来源:互联网 发布:知乎邮箱注册 编辑:程序博客网 时间:2024/05/21 17:57
#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;// 题目链接:http://acm.fzu.edu.cn/problem.php?pid=1523/* 博弈DP*/int dp[10][10][10][10];int n, p1, p2, p3, p4;int main() { scanf("%d", &n); while(n--) { scanf("%d %d %d %d", &p1, &p2, &p3, &p4); dp[0][0][0][0] = 1; for(int i = 0; i <= p1; ++i) { for(int j = 0; j <= p2; ++j) { for(int k = 0; k <= p3; ++k) { for(int l = 0; l <= p4; ++l) { if(i+j+k+l == 0) continue; dp[i][j][k][l] = 0; for(int c = 1; c <= 3 && i - c >= 0; ++c) { dp[i][j][k][l] |= (dp[i-c][j][k][l]^1); } for(int c = 1; c <= 3 && j - c >= 0; ++c) { dp[i][j][k][l] |= (dp[i][j-c][k][l]^1); } for(int c = 1; c <= 3 && k - c >= 0; ++c) { dp[i][j][k][l] |= (dp[i][j][k-c][l]^1); } for(int c = 1; c <= 3 && l - c >= 0; ++c) { dp[i][j][k][l] |= (dp[i][j][k][l-c]^1); } } } } } if(dp[p1][p2][p3][p4]) { printf("1\n"); } else { printf("0\n"); } } return 0;}
0 0
- FOJ 1523 A Version of Nim
- fzoj 1523 A Version of Nim(DP)
- 省SD2017 A Return of the Nim【威佐夫博弈+NIM】
- A set of ADO Classes - version 2.10
- Debugging the release version of a program
- 山东省第八届省赛A题 Return of the Nim
- 山东省第八届ACM省赛A.Return of the Nim
- qwb has a lot of Coins 【Nim博弈】
- ***qwb has a lot of Coins nim博弈
- Return of the Nim----Nim博弈+威佐夫博弈 山东省第八届省赛A题
- 端午个人赛-A return of Nim (Nim+威左夫,拓:巴什)
- 2017 省赛 山东 A Return of the Nim 【博弈】【Nim+Wythoff】
- A modified version of a good lrc player.
- FOJ 1106 Sum of Factorials
- FOJ 2074 Number of methods
- 【FOJ 1106】Sum of Factorials
- FOJ 1319 Blocks of Stones
- foj 1911 Construct a Matrix
- 百度李彦宏:互联网的未来发展有两种结局
- hdu 折线分割平面 (java)
- thread, looper, handler vs ScheduledExecutorService
- Codeforces Round #240 (Div. 1)---B.Mashmokh and ACM(dp)
- 字符编码
- FOJ 1523 A Version of Nim
- http://developer.baidu.com/map/jsdemo.htm#a2_1
- Eclipse Shell for Plugin
- FOJ 1381 Regular Expressions
- HDU-2010
- Eclipse导入到web项目没有run on server
- 百度地图网址
- matlab做garch模型
- linux下的~/