• HDU 2516 取石子游戏(斐波那契博弈)


    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 6590    Accepted Submission(s): 3981


    Problem Description
    1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".
     
    Input
    输入有多组.每组第1行是2<=n<2^31. n=0退出.
     
    Output
    先取者负输出"Second win". 先取者胜输出"First win".
    参看Sample Output.
     
    Sample Input
    2 13 10000 0
     
    Sample Output
    Second win Second win First win
     
    Source
     
    Recommend
    lcy   |   We have carefully selected several similar problems for you:  2509 2512 1536 2510 1907 
     
     
     
    裸的斐波那契博弈
    当输入的数据为斐波那契数的时候先手胜,否则后手胜
     
    #include<cstdio>
    #include<map>
    int fib[233],x;
    std::map<int,bool>mp;
    int main()
    {
        fib[1]=1;fib[2]=1;
        for(int i=3;i<=50;i++) fib[i]=fib[i-1]+fib[i-2],mp[fib[i]]=1;
        while(scanf("%d",&x)&&x!=0)
            puts(mp[x]==1?"Second win":"First win");
        return 0;
    }
  • 相关阅读:
    JDBC MySQL 实例之 用户管理系统
    利用JDBC连接数据库(MySQL)
    CSS01
    HTML01
    GUI编程02
    GUI编程01
    名词解释
    Navicat MySQL安装
    Eclipse安装Web/JavaEE插件、Eclipse编写HTML代码
    Pascal输出星星
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/8468648.html
Copyright © 2020-2023  润新知