JZOJ.5306【NOIP2017模拟8.18】棋盘游戏
威佐夫博弈
$t=\left\lfloor \dfrac {\left( 1+\sqrt {5}\right) \left( y-x\right) } {2}\right\rfloor \left( y>x\right)$
如果t=x则先手必败
否则先手必胜。
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 using namespace std; 5 int x,y,t,qwq; 6 int main(){ 7 scanf("%d",&t); 8 while (t--){ 9 scanf("%d%d",&x,&y); 10 if (x>y) swap(x,y); 11 qwq=floor((1+sqrt(5))/2*(y-x)); 12 if (qwq==x) printf("Alphago\n"); 13 else printf("Amphetamine\n"); 14 } 15 return 0; 16 }
To be continue......