[原博客] POJ 2505 A multiplication game 组合游戏
2014-09-07 23:47
239 查看
题目链接
题意: 有一个数
必胜状态:存在一种走法走到一个必败状态。
必败状态:后继状态都为必胜状态。
我们可以知道
ps.
View Code
题意: 有一个数
p=1,甲乙两人轮流操作,每次可以把p乘2~9中的一个数,给定一个
n,当一个人操作后
p>=n,那么这个人赢,问先手是否必胜。
必胜状态:存在一种走法走到一个必败状态。
必败状态:后继状态都为必胜状态。
我们可以知道
>=n的数都为必败状态,可以转移到
>=n的最小的数为
n/9(上取整),所以
n/9~
n-1都为必胜态,同理
n/9/2(都为上取整)为最小的必须转移到
n/9~
n-1(必胜状态)的状态,所以
n/9/2~
n/9-1为必败态,于是就可以这样推到
1,看一下
1是必胜态还是必败态输出即可。
ps.
a/b(上取整)可以写为
(a-1)/b+1(整除)。方便运算。
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> //by zrt //problem: using namespace std; typedef long long LL; const int inf(0x3f3f3f3f); const double eps(1e-9); int main(){ #ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif LL n; while(~scanf("%lld",&n)){ bool ok; while(1){ LL p=(n-1)/9+1; if(1>=p){ ok=1;break; }else n=p; p=(n-1)/2+1; if(1>=p){ ok=0;break; }else n=p; } if(ok){ puts("Stan wins."); }else{ puts("Ollie wins. "); } } return 0; }
View Code
相关文章推荐
- poj 2505 A multiplication game
- POJ 1067 威佐夫博弈(Wythoff Game)问题 (取石子游戏)
- poj 1067 取石子游戏(博弈+威佐夫博奕(Wythoff Game))
- POJ_1067 取石子游戏(Wythoff Game)
- POJ 3922 A simple stone game(K倍减法游戏)
- POJ 3922 A simple stone game(K倍减法游戏)(*)
- HDU 1527 (POJ 1067) 取石子游戏 Wythoff Game
- POJ 2068 Nim 组合游戏
- POJ 3922 A simple stone game(K倍减法游戏)
- poj 1067 取石子游戏(博弈+威佐夫博奕(Wythoff Game))
- uva 1378 - A Funny Stone Game(组合游戏)
- 【Game】组合游戏入门
- HDU 2486 (HDU 2580, POJ 3922) A simple stone game K倍动态减法游戏
- [原博客] POJ 2425 A Chess Game
- POJ 3922 A simple stone game(K倍减法游戏)
- POJ 1753 (组合+递归) Flip game 简单易懂的源代码
- [原博客] 组合游戏学习
- POJ 1067 取石子游戏 威佐夫博奕 Wythoff Game
- POJ Christmas Game [树上删边游戏 Multi-SG]
- POJ 2348 Euclid's Game 组合游戏