zoj博弈月赛

Help Bob


Time Limit: 2 Seconds      Memory Limit: 65536 KB



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

3
4

Sample Output1

win

win
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0) printf("fail\n");
        else printf("win\n");
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-11-29 07:45:12

zoj博弈月赛的相关文章

ZOJ 3529 A Game Between Alice and Bob (分解质因数+Nim博弈)

A Game Between Alice and Bob Time Limit: 5 Seconds      Memory Limit: 262144 KB Alice and Bob play the following game. A series of numbers is written on the blackboard. Alice and Bob take turns choosing one of the numbers, and replace it with one of

记次浙大月赛 134 - ZOJ Monthly, June 2014

链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类关系题目还是比较常见的,有空深究一下. 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6

zoj 月赛

141 - ZOJ Monthly, July 2015 - H Twelves Monkeys Time Limit: 5 Seconds      Memory Limit: 32768 KB James Cole is a convicted criminal living beneath a post-apocalyptic Philadelphia. Many years ago, the Earth's surface had been contaminated by a virus

ZOJ 3666 Alice and Bob (SG博弈)

题目: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 题意: 给一个有向图,然后A和B轮流移动棋子,棋子在每一个位置可以重叠,当某人不能走时,输! 问A和B谁赢 方法: 显然每一局游戏都是独立的,对每一局游戏异或即可 每一局游戏的结果可以用SG求,记忆化搜索之 1 int dfs(int x) 2 { 3 if (sg[x] != -1) return sg[x]; 4 bool vis[maxn]; 5 me

Beans Game(博弈 | | DP)zoj 3057

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

ZOJ 2015 10月份 月赛 3911 Prime Query

这道题我改啊,改啊,交啊,就对了. #include <stdio.h> #include <stdlib.h> #include <math.h> #include<cstring> #include<algorithm> using namespace std; const int N = 10000005; const int M = 100005; int a[N]; int p[M]; int tree[M*4],cover[M*4];

ZOJ Monthly, June 2014 月赛BCDEFGH题题解

比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不能加油的站就会wa..太弱.. 唔···太懒第二天才发题解.. B:Gears 并查集 题解:点击打开链接 C:Consecutive Blocks 离散化一下然后模拟 题解:点击打开链接 D:An Easy Game 设dp[i][j]为前i个位置已经匹配了j个位置的方法数. #include <

ZOJ 2686 Cycle Game(博弈 找规律)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1686 Here is a game played on a cycle by two players. The rule of this game is as follows: At first, a cycle is given and each edge is assigned a non-negative integer. Among those intege

zoj 3882 Help Bob(zoj 2015年7月月赛)

Help Bob Time Limit: 2 Seconds      Memory Limit: 65536 KB 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