题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846
巴什博弈的模版题,当n%(m+1)==0时,后手胜;其他时,先手胜。
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m;
scanf("%d%d",&n,&m);
if(n%(m+1)==0)
printf("second\n");
else
printf("first\n");
}
return 0;
}