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 ...
随机推荐
- 使用ffmpeg为影片添加字幕
ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4 The order of -c copy -c:s mov_t ...
- Git操作:绑定上传已存在的仓库到Github
之前使用github都是创建一个全新的仓库,然后clone下来用,但如果我已经有一个正在使用的仓库,想要绑定上传已存在的仓库到github,怎么做呢?其实在github创建仓库的时候会提示: …or ...
- 【01】HTML_day01_03-HTML常用标签
typora-copy-images-to: media 第01阶段.前端基础.HTML常用标签 学习目标 理解: 相对路径三种形式 应用 排版标签 文本格式化标签 图像标签 链接 相对路径,绝对路径 ...
- TNS-01189 During Listener Monitoring Using Enterprise Manager
oracle 12.2 RAC监听日志报错:15-JAN-2020 22:27:53 * (CONNECT_DATA=(COMMAND=VERSION)) * version * 1189TNS-01 ...
- CF1310D Tourism
吐槽: 为什么这场CF-不寻常,1D不应该是2F么-[悲] 题意: 给定一个完全图,路径带权且 \(dis_{i,j}\) 不一定等于 \(dis_{j,i}\),边数为\(k\)不存在奇环且起点和终 ...
- Node.js核心模块-net
net.Socket 类 socket.remotePort 访问服务器的远程端口 const http = require('http'); const server = http.createSe ...
- MySQL 8 在一台机器上运行多个MySQL实例
可以为每个实例使用一个MySQL Server二进制程序,也可以为不同实例使用同一个MySQL Server二进制程序. 不管哪一种选择,部分参数可能需要不同配置,以避免多个实例之间的冲突. 可能需要 ...
- STL中的Set和Map——入门新手篇
STL中的Set和Map 先来看一段网络上的文字描述: 上图是一段关于STL中Set集合的描述,同样的,也近似适合Map的描述.上述文字中,描述了最为重要的特征: Set和Map,底层调用了红黑树的结 ...
- 【python基础语法】运算符&if条件语句&while循环&for循环(第5天课堂笔记)
""" if语法规则: if 条件比较语句1: # 条件成立的时候 会执行的代码 elif 条件比较语句2: # 条件2成立的时候 会执行的代码 else: # 条件不成 ...
- Centos7 虚拟机安装增强功能
1 yum update kernel -y yum install kernel-headers kernel-devel gcc make -y init 6 2 菜单栏--设备--安装增强工具 ...