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的更多相关文章

  1. hdu2516斐波那契博弈

    刚开始想用sg函数做,想了半天没一点思路啊. 原来这是一个新题型,斐波那契博弈 斐波那契博弈模型:有一堆个数为 n 的石子,游戏双方轮流取石子,满足:1. 先手不能在第一次把所有的石子取完:2. 之后 ...

  2. 取石子游戏 HDU2516(斐波那契博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2516 题目: Problem Description 1堆石子有n个,两人轮流取.先取者第1次可以取任 ...

  3. 20-取石子动态规则(hdu2516 斐波那契博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=2516 取石子游戏 Time Limit: 2000/1000 MS (Java/Others)    Memor ...

  4. HDU2516 - 取石子游戏【斐波那契博弈】

    基本描述 有一堆个数为n的石子,游戏双方轮流取石子,满足: 先手不能再第一次把所有石子取完: 之后每次可以取的石子数介于1到对手刚取的石子数的2倍之间,包括1和对手取的石子数的2倍.  取最后石子的人 ...

  5. hdu2516 博弈

    找规律,发现时斐波那契数列:打表上. #include<stdio.h> #include<string.h> #define maxn 2147483647 __int64 ...

随机推荐

  1. Windows ping

    用法: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]            [-r count] [-s count] [[-j ...

  2. 大数据之hadoop小文件存档

    hadoop小文件存档1.HDFS存档小文件弊端 每个文件均按块存储,每个块的元数据存储在NameNode的内存中,因此HDFS存储小文件会非常低效.因为大量的小文件会耗尽NameNode中的大部分内 ...

  3. JLOI 2013 卡牌游戏 bzoj3191

    题目描述 N个人坐成一圈玩游戏.一开始我们把所有玩家按顺时针从1到N编号.首先第一回合是玩家1作为庄家.每个回合庄家都会随机(即按相等的概率)从卡牌堆里选择一张卡片,假设卡片上的数字为X,则庄家首先把 ...

  4. selenium - 截图下载图片

    from selenium import webdriver from selenium.webdriver import ChromeOptions from time import sleep f ...

  5. 19.SimLogin_case04

    # 利用cookies登录马蜂窝 import requests from lxml import etree session = requests.Session() phone_number = ...

  6. pycharm IDE在导入自定义模块时提示有错,但实际没错

    在建立python项目时,有时为了区分资源和代码,如在项目文件夹下新建img和src两个文件夹,这时导入自定义模块会提示错误,结果没错但感觉别扭.如: 这是因为pycharm提示功能是从根目录上去寻找 ...

  7. 移植 thttpd Web 服务器

    下载 从 http://www.acme.com/software/thttpd/下载 thttpd 到/tmp 目录当中,并解压. 编译 thttpd [arm@localhost thttpd­2 ...

  8. 微信小程序前后台调用

    // pages/ruquestexer/index.js Page({ /** * 页面的初始数据 */ data: { }, getUserData:function(){ wx.request( ...

  9. atom的使用

    一,Atom介绍 Atom 是 Github 开源的文本编辑器,这个编辑器完全是使用Web技术构建的(基于Node-Webkit).启动速度快,提供很多常用功能的插件和主题,可以说Atom已经足以胜任 ...

  10. 【daydayup】ceshuChat

    时时当勉励,岁月不待人.珍惜时间伐~ 先看看项目运行的效果 这个是在本地环境打开了两个8080端口进行模拟运行的. 先放下作者的开源地址:https://github.com/ceshu/ceshuC ...