正解:博弈论

解题报告:

传送门!

首先按照套路显然是考虑先预处理出所有数的$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. 下载mysql document

    wget -b -r -np -L -p https://dev.mysql.com/doc/refman/5.6/en/ 在下载时.有用到外部域名的图片或连接.如果需要同时下载就要用-H参数. wg ...

  2. python----操作Memcache、redis、RabbitMQ、SQLAlchemy

    操作本质都是通过socket发送命令 Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次 ...

  3. oracle函数 add_months(d1,n1)

    [功能]:返回在日期d1基础上再加n1个月后新的日期. [参数]:d1,日期型,n1数字型 [返回]:日期

  4. oracle函数 NLS_UPPER(x[,y])

    [功能]返回字符串并将字符串的转换为大写; [参数]x字符型表达式 [参数]Nls_param可选,指定排序的方式(nls_sort=) . SCHINESE_RADICAL_M(部首.笔画) SCH ...

  5. oracle函数 LOWER(c1)

    [功能]:将字符串全部转为小写 [参数]:c1,字符表达式 [返回]:字符型 [示例] SQL> select lower('AaBbCcDd')AaBbCcDd from dual; AABB ...

  6. ng-model 将时间戳转换为标准时间

      html部分 <div class="form-group loginCon1"> <label class="col-sm-2 control-l ...

  7. laravel5.6 发送邮件附带邮件时,Unable to open file for reading,报错文件路径问题

    https://stackoverflow.com/questions/48568739/unable-to-open-file-for-reading-swift-ioexception-in-la ...

  8. 解决margin塌陷和margin合并

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. SQL 三个表练习(student,teacher,score)

  10. 第3本:Visual Studio程序员箴言

    第3本:Visual Studio程序员箴言 Visual Studio 2010是我经常使用的程序开发工具,也知道VS中有大量的快捷键可以帮助提高效率,可惜就是不愿意记忆,最近在学vim的时候快速把 ...