这个问题就是OJ题里出现的取石子游戏,http://en.wikipedia.org/wiki/Wythoff%27s_game. 维基里面的通项公式并不适用于算法求解.需要理解下面两条规律: 1.As is true in general for pairs of Beatty sequences, these two sequences are complementary: each positive integer appears exactly once in either sequen…
题意:Wythoff Game 思路:Wythoff Game #include<iostream> #include<stdio.h> #include<math.h> using namespace std; int main(){ int a,b,t; )+)/;//黄金比例 golden ratio double a2; while(~scanf("%d%d",&a,&b)){ if(a>b){ t=a; a=b; b=…
SG函数先不说,给自己总结下三大博弈.和二进制及黄金分割联系密切,数学真奇妙,如果不用考试就更好了. 1.Bash Game:n个物品,最少取1个,最多取m个,先取完者胜. 给对手留下(m+1)的倍数肯定获胜.若n%(m+1)==0,先手必败. 51nod裸题:1066 #include <iostream> #include <cstdio> using namespace std; int main(){ int t; cin>>t; int n,k; while(…