hdu_1848(SG函数)
来源:互联网 发布:澳洲gdp数据 编辑:程序博客网 时间:2024/06/07 03:02
博弈论SG函数的最基本用法,
代码参考:http://www.cnblogs.com/vongang/archive/2011/09/24/2189393.html
#include<stdio.h>#include<string.h>#include<algorithm>int main(){int sg[1000+100];int f[100];f[1]=1,f[2]=2;int i,q,w;for(i=3;;i++){f[i]=f[i-1]+f[i-2];if(f[i]>=1000+100)break;}sg[0]=0;sg[1]=1;int hash[30];for(i=1;i<=1000+99;i++){memset(hash,0,sizeof(hash));for(q=1;f[q]<=i;q++){hash[sg[i-f[q]]]=1;}for(q=0;q<=30;q++){if(hash[q]==0) { sg[i]=q; break; }}}int a,b,c;while(scanf("%d%d%d",&a,&b,&c)!=EOF){if(a==0||b==0||c==0)break;if(sg[a]^sg[b]^sg[c]){printf("Fibo\n");}else printf("Nacci\n");}return 0;}
0 0
- hdu_1848(SG函数)
- HDU_1848 Fibonacci again and again(SG)
- sg函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- SG函数
- sg函数
- SG函数
- SG函数
- SG函数
- sg函数
- SG函数
- [SDN]OpenFlow报头解析
- 【剑指offer】(扩展)求链表中间结点
- c高级c存储类型
- sql查询优化 索引优化
- c高级字长字节序对齐
- hdu_1848(SG函数)
- Java面试汇总
- 困扰我的isset/empty函数
- leetcode_335 Self Crossing
- [bzoj1014][JSOI2008]火星人prefix
- Eclipse Mars中Cordova 开发
- c高级预处理
- 翻墙?隐私?今天聊聊VPN的那些事儿
- 拉格朗日插值法