hdoj 5754 Life Winner Bo
2016-07-27 00:43
399 查看
这把多校打得非常崩,来补一下。找规律的话,感觉后是最难的,马次之,好久不碰威佐夫博弈了,复习一下,模型是这样的:有两堆石子,两人轮流拿,可以从其中一堆拿任意个,或者两堆拿相同个数,拿完的人赢。假设当前两堆分别是n和m(m>n),必败状态是n=(m−n)∗(5√+1)/2。后打表也可以(我的第一发AC就是打表的)。
#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> #include <string> #include <string.h> #include <vector> #include <queue> #include <stack> #include <map> #include <sstream> using namespace std; #define ll long long int main(){ int t; cin>>t; while(t--){ int n,m; int type; cin>>type>>n>>m; n--; m--; if(type == 1){ //king if( (n%2) == 0 && (m%2) == 0){ puts("G"); }else{ puts("B"); } } else if(type == 2){ //rook if(n==m){ puts("G"); }else{ puts("B"); } }else if (type == 3){ //knight if((n+m)%3==0){ if(n==m){ puts("G"); }else{ if(n<m){ swap(n,m); } n-=2; m-=1; if(n==m){ puts("B"); }else{ puts("D"); } } }else{ puts("D"); } }else{ //queen if(n<m){ swap(n,m); } int delta = n-m; if( m == (int)(delta*(sqrt(5)+1)/2) ){ puts("G"); }else{ puts("B"); } } } return 0; }
相关文章推荐
- 博弈问题
- 取石子游戏
- 威佐夫(Wythoff)博弈
- 威佐夫博弈
- HDU 1527 取石子游戏 (博弈)
- HDU 2177 威佐夫博弈
- ACM-威佐夫博弈之取石子游戏——hdu1527
- ACM-威佐夫博弈之取(2堆)石子游戏——hdu2177
- HDOJ1527 [威佐夫博弈]【典型】
- HDOJ2177 [威佐夫博弈](输出方案)
- HDU 1527 (POJ 1067) 取石子游戏 Wythoff Game
- Codeforces Gym 100379I Move the queen to the corner! 威佐夫博弈变形 + 高精度
- POJ 1067 取石子游戏(威佐夫博弈)
- 巴氏(bash)威佐夫(Wythoff)尼姆(Nim)博弈之模板
- 杭电1527-取石子游戏(威佐夫博弈)
- HDOJ 取石子游戏(威佐夫博弈)
- 威佐夫博弈(2堆)应用-- HDU 1527 取石子游戏
- 威佐夫博弈(2堆)--取石子游戏(将胜态转变成必败态)
- POJ-1067 取石子游戏(威佐夫博弈)
- poj1067 取石子游戏