我该如何去触摸这类问题嘞!

取石子游戏

1堆石子有n个,两人轮流取.

先取者第1次可以取任意多个,但不能全部取完.

以后每次取的石子数不能超过上次取子数的2倍。

取完者胜.先取者负输出"Second win".先取者胜输出"First win".

  输入有多组.每组第1行是2<=n<2^31. n=0退出.

  先取者负输出"Second win". 先取者胜输出"First win".

Sample Input

2
13
10000
0
Sample Output
Second win
Second win
First win
先手面对的只要是斐波那契数,都是必败点,先手必败。
#include<iostream>
#include<cstdio>
using namespace std;
int fib[45]={2,3};
void f()
{
for(int i=2;i<45;i++)
fib[i]=fib[i-1]+fib[i-2];
} int main()
{
int n;
f();
while(~scanf("%d",&n) && n)
{
int i;
for(i=0;i<45;i++)
{
if(n==fib[i])
{
puts("Second win");
break;
}
}
if(i==45) puts("First win");
}
return 0;
}

  Link:

https://blog.csdn.net/Dog_dream/article/details/80445886

https://www.cnblogs.com/cancangood/p/3515855.html

https://blog.csdn.net/dgq8211/article/details/7602807

pick the stone game的更多相关文章

  1. POJ 1694 An Old Stone Game【递归+排序】

    链接: http://poj.org/problem?id=1694 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...

  2. POJ 1694 An Old Stone Game

    题目: Description There is an old stone game, played on an arbitrary general tree T. The goal is to pu ...

  3. POJ1740A New Stone Game[组合游戏]

    A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5769   Accepted: 3158 ...

  4. POJ 1740 A New Stone Game

    A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5453   Accepted: 2989 ...

  5. 【POJ】A New Stone Game(博弈论)

    http://poj.org/problem?id=1740 题目大意就是,对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分 ...

  6. 【UVA1378】A Funny Stone Game (博弈-求SG值-输出方案)

    [题目] Description The funny stone game is coming. There are n piles of stones, numbered with 0, 1, 2, ...

  7. 博弈论(男人八题):POJ 1740 A New Stone Game

    A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5694   Accepted: 3119 ...

  8. poj 1740 A New Stone Game(博弈)

    A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5338   Accepted: 2926 ...

  9. POJ 1740:A New Stone Game

    A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5113 Accepted: 2806 Desc ...

随机推荐

  1. XOR and Favorite Number CodeForces - 617E

    a[i]^a[i+1]--a[j]=k; 处理前缀和pre[i] 那么上式可以表示为pre[i-1]^pre[j]=k; #include<bits/stdc++.h> using nam ...

  2. JN_0019:CMD命令窗口常用操作

    1,回到根目录下 cd\ 2,

  3. 使用CSV Data Set Config配置原件,参数化数据

    对接口数据的参数化方式大概有三种方式,1:jmeter内置函数:2:借助CSV Data Set Config配置原件:3:jdbc连接数据库,使用数据表字段 此处主要讲第二种:借助CSV Data ...

  4. 树莓派搭载CentOS7系统初始配置

    系统属性: 树莓派型号:3b SD:32GB 系统:CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1908-sda.raw 开机配置: 连接树莓派: 配件 ...

  5. Python学习笔记———递归遍历多层目录

    import os #得到当前目录下所有的文件 def getALLDir(path,sp = ""): filesList = os.listdir(path) #处理每一个文件 ...

  6. Oracle12c传统数据库模式 OGG

    OGG12C 配置 环境配置: 安装数据库Oracle12c 安装源端OGG:oggs  PORT:7809 安装目标端OGG:oggt   PORT:7909 源端和目标端地址:127.0.0.1 ...

  7. opencv —— createTrackbar、getTrackbarPos 滑动条的创建和使用

    创建滑动条:createTrackbar 函数 createTrackbar 函数用于创建一个可以调整数值的滑动条,并将滑动条附加在指定的窗口上. int createTrackbar(const s ...

  8. composer封装dd函数

    1.安装composer,本人用的phpstudy,打开php扩展php_openssl 2.切换到www目录下 cmd 命令 composer 第一个就是我们要找的 3.运行composer req ...

  9. JVM和线程池

    本文链接:https://blog.csdn.net/liuwenliang_002/article/details/90074283 ————————————————版权声明:本文为CSDN博主「3 ...

  10. Wannafly Winter Camp 2020 Day 5B Bitset Master - 时间倒流

    有 \(n\) 个点的树,给定 \(m\) 次操作,每个点对应一个集合,初态下只有自己. 第 \(i\) 次操作给定参数 \(p_i\),意为把 \(p_i\) 这条边的两个点的集合合并,并分别发配回 ...