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

取石子游戏

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. Java架构-高并发的解决实战总结方案

    Java架构-高并发的解决实战总结方案 1.应用和静态资源分离 刚开始的时候应用和静态资源是保存在一起的,当并发量达到一定程度的时候就需要将静态资源保存到专门的服务器中,静态资源主要包括图片.视频.j ...

  2. C#中的WinFrom技术实现串口通讯助手(附源码)

    C#中的WinFrom技术实现串口通讯助手(附源码)   实现的功能: 1.实现自动加载可用串口. 2.打开串口,并且使用C#状态栏显示串口的状态. 3.实现了串口的接收数据和发送数据功能. 4.串口 ...

  3. Python面向对象设计小结

    转自林海峰老师,学习之余做的笔记. class School: zhuti='学生和老师‘ def __init__(self,name,dic,country): self.mingzi=name ...

  4. RedisDeskTopManager连接时提示:can't nonnect to redis-server

    场景 在使用RedisDeskTopManager客户端可视化工具连接Redis服务端时提示: 注: 博客: https://blog.csdn.net/badao_liumang_qizhi关注公众 ...

  5. spring boot tomcat 部署

    前几天springboot项目部署到linux中,整个过程就是个坑啊.踩坑的过程中也学到了许多.spring boot 项目部署时由于其内置了tomcat和jdk,而且还都是8. 所以部署的话就分为两 ...

  6. 关于对 softirq、work_queue、tasklet 学习后的一点总结

    本文基于linux版本:4.14.111 简单的总结下 softirq.work_queue.tasklet 三种中断下半部的工作原理及区别,并附上三种形式的简单实例. 一.运行原理① softirq ...

  7. 剑指offer-拓展训练-字符的所有组合-全组合

    /* 题目: 给定不含重复字符字符串的全组合. */ /* 思路: 递归法. 例给定abc,输出的组合长度为1,2,3. 对于长度为2的组合,分选择a(ab,ac)和不选择a的情况(bc). 选择a, ...

  8. const 函数

    const int *p   // 修饰*p ,p指针可以变,但是*p的值不变 例子: int a = 5; int b = 10; const *p = &a; *p = 10: // 不可 ...

  9. C语言 杂货整理

    C语言 杂货整理 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include ...

  10. H5解决active伪类失效---点击后背景效果

    <body ontouchstart></body> 给body注册一个空事件即可