hdu2516
hdu2516
斐波那契博弈,也是一堆博弈的一种,第一个人第一次可以拿任意多,但是不能取完,第二个人拿至少一个,但不能超过上一个人拿的两倍
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
long long f[],n;
void in(long long &x){
long long y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(long long x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main(){
f[]=f[]=;
For(i,,)
f[i]=f[i-]+f[i-]; while(cin>>n&&n){
if(binary_search(f+,f+,n))
puts("Second win");
else
puts("First win");
}
return ;
}
hdu2516的更多相关文章
- hdu2516斐波那契博弈
刚开始想用sg函数做,想了半天没一点思路啊. 原来这是一个新题型,斐波那契博弈 斐波那契博弈模型:有一堆个数为 n 的石子,游戏双方轮流取石子,满足:1. 先手不能在第一次把所有的石子取完:2. 之后 ...
- 取石子游戏 HDU2516(斐波那契博弈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2516 题目: Problem Description 1堆石子有n个,两人轮流取.先取者第1次可以取任 ...
- 20-取石子动态规则(hdu2516 斐波那契博弈)
http://acm.hdu.edu.cn/showproblem.php?pid=2516 取石子游戏 Time Limit: 2000/1000 MS (Java/Others) Memor ...
- HDU2516 - 取石子游戏【斐波那契博弈】
基本描述 有一堆个数为n的石子,游戏双方轮流取石子,满足: 先手不能再第一次把所有石子取完: 之后每次可以取的石子数介于1到对手刚取的石子数的2倍之间,包括1和对手取的石子数的2倍. 取最后石子的人 ...
- hdu2516 博弈
找规律,发现时斐波那契数列:打表上. #include<stdio.h> #include<string.h> #define maxn 2147483647 __int64 ...
随机推荐
- dp转图论——cf1070A好题
dp的状态转移很像一张有向图:每个状态为一个点,每中转移方案是一条有向边 本题要求是求出最小的数,那我们用状态[i,j]表示模i,数位和为j,那么从每个点出发的十条有向边代表[0,9]十个数 从每个状 ...
- DP杂题2
1.邦邦的大合唱站队 https://www.luogu.org/problem/show?pid=3694 XY说这是道简单的签到题,然后我大概是普及组都拿不到三等的那种了.. 插入题解.写得太好了 ...
- HttpClient 使用案例
package com.qifeng.config.ygx.common.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fas ...
- svg实现渐变进度圆环
效果图 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="ut ...
- System.Web.Mvc.HttpHeadAttribute.cs
ylbtech-System.Web.Mvc.HttpHeadAttribute.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, ...
- Spring Cloud Config的配置中心使用非对称性加密
首先,我们需要通过keytool工具来生成密钥对. keytool是JDK中的一个密钥和证书管理工具.它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认 ...
- PAT甲级——A1138 Postorder Traversa【25】
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and in ...
- IO初步,字节输入流和字节输出流
字节输出流 OutputStream(基类,抽象) 特点:写任意的文件 方法:写出数据的方法:write write(int b) 写出1个字节 -128~127之间,写的是一个ASCLL码的值 wr ...
- jquery对于ajax的封装
第一层封装 $.ajax({ 属性名:值,属性名:值}) /* url: 请求服务器地址 data:请求参数 dataType:服务器返回数据类型 error 请求出错执行的功能 success 请求 ...
- 华为-eNSP模拟器路由器无法正常启动一直显示“#”
问题项如截图: 解决方案: 1. 打开自己电脑的控制面板 -->> 系统和安全 -->> Windows Defender防火墙 (运行应用通过Windows防火墙) 2 .找 ...