description
这个游戏上在一个无限大的棋盘上, 棋盘上只有一颗棋子在位置(x,y)(x,y>=0)棋盘的左下角是(0,0)
Amphetamine每次都是第一个移动棋子,然后Amphetamine与Alphago轮流移动。每一轮可以做以下三种中的一种操作:
1)在同一行,将棋子从当前位置向左移动任意格;
2)在同一列,将棋子从当前位置向下移动任意格;
3)将棋子从当前位置向下移动k格再向左移动k格(k为任意正整数,且要满足移动后的棋子仍然在棋盘上)
第一个不能在棋盘上移动的人比赛算输(因为棋子处在(0,0)点)。
共有T个回合(1<=T<=1,000),每次给出一个新起始点的坐标(x,y),确定是谁赢。
solution
这个叫威佐夫博弈,x
code
#include<set>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=begin[j];i;i=next[i])
using namespace std;
int const mn=5*1e5+9,mo=1e9+7;
int t,n,m;
int main(){
freopen("d.in","r",stdin);
freopen("d.out","w",stdout);
scanf("%d",&t);
fo(cas,1,t){
scanf("%d%d",&n,&m);
if(n>m)swap(n,m);
if(floor((sqrt(5.0)+1.0)/2.0*(m-n))==n)printf("Alphago\n");
else printf("Amphetamine\n");
}
return 0;
}