题目链接:Brave Game - HDU 1846 - Virtual Judge (ppsucxtt.cn)
题目是中文的,我在这就不翻译题意了,这道题目显然是一道巴什博弈题,所以只需要我们判断n与m+1的关系就行了,倘若n可以被m+1整除,则先手必输,否则后手必输。
如果还不太明白巴什博弈的小伙伴可以看下我之前的博客,我在这附上博客地址:
(34条消息) 博弈论总结_AC__dream的博客-CSDN博客
下面是代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
int n,m;
scanf("%d%d",&n,&m);
if(n%(m+1)) puts("first");
else puts("second");
}
return 0;
}