pick the stone game
我该如何去触摸这类问题嘞!
取石子游戏
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的更多相关文章
- POJ 1694 An Old Stone Game【递归+排序】
链接: http://poj.org/problem?id=1694 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...
- 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 ...
- POJ1740A New Stone Game[组合游戏]
A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5769 Accepted: 3158 ...
- POJ 1740 A New Stone Game
A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5453 Accepted: 2989 ...
- 【POJ】A New Stone Game(博弈论)
http://poj.org/problem?id=1740 题目大意就是,对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分 ...
- 【UVA1378】A Funny Stone Game (博弈-求SG值-输出方案)
[题目] Description The funny stone game is coming. There are n piles of stones, numbered with 0, 1, 2, ...
- 博弈论(男人八题):POJ 1740 A New Stone Game
A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5694 Accepted: 3119 ...
- poj 1740 A New Stone Game(博弈)
A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5338 Accepted: 2926 ...
- POJ 1740:A New Stone Game
A New Stone Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5113 Accepted: 2806 Desc ...
随机推荐
- 关于Redis缓存预热的思考
系统上线时,提前将相关的缓存数据直接加载到缓存系统.避免在用户请求的时候,先查询数据库,然后再将数据缓存的问题. 这里我考虑2个问题: A.哪些数据需要预热? B.如何预热? 关于问题A,根据不同的业 ...
- Python股票量化第一步环境搭建
很久之前就希望可以量化分析股票,那么国内的股票数据API也有个,最有名的就是tushare,然后还有baostock. 今天我们就来研究一下这个baostock吧. 首先,我们需要下载一个叫做anac ...
- 有哪些「看似复杂,实则简单」的 PS 技巧?
Mac版ps2019哪里有?本次主要以组合键为主,PS中隐藏功能都是通过这些“组合技”启动的,据统计熟练地使用一系列组合技会让你的效率提升30%(纯属虚构).其中一些比较难理解的我都制作了GIF动态图 ...
- SQL server 游标用法
declare @EmpCode varchar(50), @EmpName varchar(50), @EmpAddress varchar(200);declare curEmployee cur ...
- 清北学堂—2020.1提高储备营—Day 3(图论初步(二))
qbxt Day 3 --2020.1.19 济南 主讲:李奥 目录一览 1.图论(kruskal算法,最短路径算法,拓扑排序) 总知识点:图论 一.kruskal算法 1.目的:求图的最小生成树 2 ...
- gRPC搭建使用方式
gRpc 官网 链接 新建服务端项目 在服务端内先编写一个 .proto 文件 greet.proto syntax = "proto3"; service Greeter { ...
- 第3种方法获取redis cluster主从关系
需求:使用cluster slots命令,获取redis cluster 主从对应关系. 说明:cluster slots命令对应的字段说明:http://redis.cn/commands/clus ...
- 洛谷P1808 单词分类_NOI导刊2011提高(01) 字符串排序
洛谷P1808 单词分类_NOI导刊2011提高(01) 题目描述 Oliver为了学好英语决定苦背单词,但很快他发现要直接记住杂乱无章的单词非常困难,他决定对单词进行分类. 两个单词可以分为一类当且 ...
- VSCode(主进程)
Overview(总览) SETUP(设定) Overview(总览) Linux(略) macOS(略) Windows 使用WSL,您可以在Windows上安装和运行Linux发行版.这使您能够在 ...
- private、public、this关键字
private关键字 概念:私有的,一种权限修饰符,用来修饰类的成员 特点:被修饰的成员只能在本类中访问 用法: - 1. private 数据类型 变量名: - 2. private 返回值类型 方 ...