zoj 3057 Beans Game 博弈论】的更多相关文章

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 典型的sg函数,数据范围卡得真好啊 代码 #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostream> #include<map> using namespace std; int m,n…
思路:三维DP,刚开始用记忆化搜索,MLE…… 后来改为直接预处理所有的情况. 总之就是必败态的后继是必胜态!!! 代码如下: #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<set> #include<vector> #define ll long long #define…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 有豆类三个桩.TT和DD挑选任意数量的豆子从任何两堆轮流任何桩或相同的数字.谁拿到最后一个Bean将获胜.TT和DD是很聪明的. #include<stdio.h> #define N 300+4 bool dp[N][N][N]={0};//用bool比int省空间 void Init(){ int i,j,k,t; for(i=0;i<N;i++) fo…
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…
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…
暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> #define M 1000000 #define ll __int64 using namespace std; ]; int get_len(int n) { ) ; ) ; ) ; ) ; ) ; ; } void solve(int n…
其实规律很好找的,当从某点开始,向某一边找出非0的个数,为奇数时必胜. 代码如下: #include<iostream> #include<cstdio> using namespace std; ]; bool dfs(int m) { ,i=m,k; )%n,cnt++; ) ; i=(m+n-)%n;cnt=; )%n,cnt++; ) ; ;i<=;i+=){ ) k=m; )%n; ;j<=a[k];j++){ a[k]-=j; if(!dfs((n+i+m)…
思路:对于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<…
在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜点和必败点的概念:        P点:必败点,换而言之,就是谁处于此位置,则在双方操作正确的情况下必败.        N点:必胜点,处于此情况下,双方操作均正确的情况下必胜. 必胜点和必败点的性质:         1.所有终结点是 必败点 P .(我们以此为基本前提进行推理,换句话说,我们以此为假设)         2.从任何必胜点N 操作,至少有一种方式可以进入必败点 P.         3.无论如何操作,必败点P 都…
在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜点和必败点的概念:        P点:必败点,换而言之,就是谁处于此位置,则在双方操作正确的情况下必败.        N点:必胜点,处于此情况下,双方操作均正确的情况下必胜. 必胜点和必败点的性质:         1.所有终结点是 必败点 P .(我们以此为基本前提进行推理,换句话说,我们以此为假设)         2.从任何必胜点N 操作,至少有一种方式可以进入必败点 P.         3.无论如何操作,必败点P 都…