zoj 3882 Help Bob(博弈)
来源:互联网 发布:怎样用淘宝客推广 编辑:程序博客网 时间:2024/05/17 03:05
题目链接
There is a game very popular in ZJU at present, Bob didn't meant to participate in it. But he decided to join it after discovering a lot of pretty girls playing it.
There are n stones on the ground and they are marked as 1 to n respectively. There will be 2 players in each competition. And the game rules are simple, A and B take turns to move. Each round, one of them can only take 1 number away, and then pick out all the divisors of the choosed number. When anyone who can not take away 1 number any longer, he will fail the whole game.
Input
There are multiple cases. Each case include an integer number n (0 ≤ n ≤ 100).
Output
For each case, A win, output "win". If not, output"fail".
Sample Input1
34
Sample Output1
winwin
题解:
若n为1先手赢
若n为0先手输
若n>1,若先手第一手不拿一,那么他所面临的状态和 先手拿一后后手所面临的状态是一样的。若第一手先手不拿一,一定必输。那么先手改变策勒拿一一定赢。若拿一必赢,则先手必赢。所以先手必赢。
代码如下:
#include<iostream>#include<stdio.h>#include<algorithm>#include<math.h>#include<queue>#include<string>#include<string.h>#include<stack>#include<vector>#include<set>#include<map>typedef long long LL;typedef unsigned long long LLU;double pi = acos(-1);const int nn = 210;const int inff = 0x3fffffff;const LL mod = 1000000007;using namespace std;int n;int main(){ while(scanf("%d",&n)!=EOF) { if(n==0) { puts("fail"); } else puts("win"); } return 0;}
- zoj 3882 Help Bob(博弈)
- ZOJ Help Bob 3882【博弈】
- (zoj 3882 Help Bob)<>
- ZOJ 3882Help Bob
- zoj 3882 Help Bob
- ZOJ-3882 Help Bob
- (博弈)Help Bob (141 - ZOJ Monthly, July 2015 )
- zoj3882 Help Bob 博弈
- ZOJ 3666 Alice and Bob(博弈)
- zoj 3882 Help Bob(zoj 2015年7月月赛)
- ZOJ 月赛 Help Bob
- ZOJ 3666 Alice and Bob(博弈 sg 函数入门)
- Help Bob (141 - ZOJ Monthly, July 2015 )
- ZOJ 3666 Alice and Bob 基础博弈
- ZOJ 3529 - A Game Between Alice and Bob(素因子+博弈)
- Alice and Bob(博弈)
- ZOJ 3529 A Game Between Alice and Bob(博弈)
- poj 1704 Georgia and Bob(博弈)
- 微信JSSDK分享接口中wx.config 出现invalid signature问题的解决办法
- HDU 1171
- POJ3258—River Hopscotch—二分法求the largest mimmun
- Qt实战之开发CSDN下载助手 (3)(结束篇)
- SSH开发——菜鸟那些事儿
- zoj 3882 Help Bob(博弈)
- 循环、数组截取、随机数的产生(2015/7/30)
- STL学习记录(十四):其它几种算法
- VS2010关于error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- ARM处理器体系架构详细说明
- uvalive 4973
- Scala学习第五天:数组的基本操作,数组的进阶操作和多维数组
- Hdu 1789 Doing Homework again
- pycharm快捷键、常用设置、包管理