正解:博弈论

解题报告:

传送门!

首先按照套路显然是考虑先预处理出所有数的$SG$函数值然后全局的$SG$就是$SG(n)$^$SG(m)$^$SG(p)$,这儿应该麻油问题$QwQ$?

然后就考虑怎么求$SG$函数?于是就直接$SG(x)=mex\{SG(x-y),y\in Fib,x\ge y\}$就好鸭$QwQ$

$over!$

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define ri register int
#define rb register bool
#define rc register char
#define rp(i,x,y) for(ri i=x;i<=y;++i) const int N=+;
int f[N],sg[N];
bool gdgs=,vis[N]; il int read()
{
rc ch=gc;ri x=;rb y=;
while(ch!='-' && (ch>'' || ch<''))ch=gc;
if(ch=='-')ch=gc,y=;
while(ch>='' && ch<='')x=(x<<)+(x<<)+(ch^''),ch=gc;
return y?x:-x;
}
il void pre()
{
f[]=;f[]=;rp(i,,)f[i]=f[i-]+f[i-];
rp(i,,){for(ri j=;f[j]<=i;++j)vis[sg[i-f[j]]]=;ri tmp=;while(vis[tmp])++tmp;sg[i]=tmp;for(ri j=;f[j]<=i;++j)vis[sg[i-f[j]]]=;}
} int main()
{
// freopen("1848.in","r",stdin);freopen("1848.out","w",stdout);
pre();
while(gdgs){ri m=read(),n=read(),p=read();if(!m && !n && !p)return ;printf(sg[m]^sg[n]^sg[p]?"Fibo\n":"Nacci\n");}
return ;
}

$HDU1848\ Fibonacci\ again\ and\ again$ 博弈论的更多相关文章

  1. 【博弈论】【SG函数】hdu1848 Fibonacci again and again

    某个状态的SG函数被定义为 除该状态能一步转移到的状态的SG值以外的最小非负整数. 有如下性质:从SG值为x的状态出发,可以转移到SG值为0,1,...,x-1的状态. 不论SG值增加与否,我们都可以 ...

  2. HDU1848 Fibonacci again and again SG函数

    Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  3. hdu-------(1848)Fibonacci again and again(sg函数版的尼姆博弈)

    Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  4. HDU1848 Fibonacci again and again(SG 函数)

    任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的: F(1)=1; F(2)=2; F(n)=F(n-1)+F(n-2)(n>=3); 所以,1, ...

  5. hdu1848 Fibonacci again and again [组合游戏]

    http://acm.hdu.edu.cn/showproblem.php?pid=1848 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers) ...

  6. hdu1848 Fibonacci again and again(SG游戏功能)

    现在的变化是看不清楚SG功能什么寻求方法 临时模板标题是首当 性能mex1它正在寻求g(x) 然后XOR #include<cstdio> #include<iostream> ...

  7. HDU.1848.Fibonacci again and again(博弈论 Nim)

    题目链接 //求三堆石子的SG函数,异或起来就是整个游戏的SG值 #include <cstdio> #include <cstring> const int N=1005; ...

  8. HDU1848 Fibonacci again and again 博弈 SG函数

    题意:三堆石子,每次能拿走斐波那契数个石子,先取完石子胜,问先手胜还是后手胜  石子个数<=1000 多组数据 题目链接:http://acm.hdu.edu.cn/showproblem.ph ...

  9. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

随机推荐

  1. Android 监听软键盘搜索键

    现在很多的Android应用都有了数据搜索功能,在以往的设计上,会使用搜索框+搜索按钮来实现搜索功能: 现在呢,越来越流行的是,去除搜索按钮,直接监听软键盘搜索键,当用户输入完搜索关键字后,直接点击软 ...

  2. vbox环境搭建oracle11g RAC过程

    安装环境 主机操作系统:windows 10 虚拟机Vbox:两台Oracle Linux R6 U7 x86_64 Oracle Database software: Oracle11gR2 Clu ...

  3. MapReduce数据流-概述

  4. uva 12003 Array Transformer (线段树套平衡树)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  5. Getting started with the basics of programming exercises_3

    1.编写一个程序删除每个输入行末尾的空格及制表符并删除完全是空白符的行 #include<stdio.h> #define MAXLINE 1000 // maximum input li ...

  6. phpstorm 中背景色的调整

  7. 为什么有时候Css样式表某个属性引用不成功?

    首次使用博客,很多东西都在探索,第一篇文章也不知道发布点什么,就随便写写,是在word里面写的,也懒得排版,将就这用吧. 闲着没事找了酷狗的API写了个简单的静态网页,完成了搜索,展示,播放功能.就想 ...

  8. 2019-11-13-如何在国内发布-UWP-应用

    title author date CreateTime categories 如何在国内发布 UWP 应用 lindexi 2019-11-13 08:46:44 +0800 2019-02-17 ...

  9. oracle用UNION替换OR (适用于索引列)

    通常情况下, 用UNION替换WHERE子句中的OR将会起到较好的效果. 对索引列使用OR将造成全表扫描. 注意, 以上规则只针对多个索引列有效. 如果有column没有被索引, 查询效率可能会因为你 ...

  10. JS正则验证两位小数,验证数字最简单正则表达式大全

    <h3>输入完按回车后即可验证!</h3> 正整数: <input type="text" size="20" onkeydown ...