• 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 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

    题目大意:

    有1到n个数字,两个人轮流选1个数。并把它的全部约数擦去。擦去最后一个数的人赢,输出先手必胜还是必败。

    解题思路:

    如果后手能赢。也就是说后手有必胜策略,使得先手第一次不管取哪个石子,后手都能获得最后的胜利。那么如今如果先手取1,接下来

    后手通过某种取法使自己进入必胜状态,可是,先手第1次取得时候就能够和后手这次取的一样,抢先进入必胜局面。于是除了0。其它都是

    必胜。

    代码:

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


  • 相关阅读:
    为Jupyter只安装目录的扩展包
    前端菜鸟的小程序摸索记录
    小计:Shopee批量删除修复~附脚本
    Python3 与 C# 并发编程之~ 协程篇
    记一次硬件故障,并普及点硬件知识
    小计:协同办公衍生出的需求
    监控MySQL|Redis|MongoDB的执行语句(go-sniffer)
    Linux IO实时监控iostat命令详解
    Linux下的磁盘缓存
    使用top命令查看系统状态
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/7256867.html
Copyright © 2020-2023  润新知