题目传送门
题目大意
有一堆石子一共有n个;
两人轮流进行;
每走一步可以取走1…m个石子;
最先取光石子的一方为胜;
思路
很明显的巴什博弈
n对m+1取模判断余数是否为0即可
AC Code
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<math.h>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
// #define int long long
#define debug(a) cout<<#a<<"="<<a<<endl;
typedef long long ll;
const double PI=acos(-1.0);
const double e=exp(1.0);
const int M=1e9+7;
const int N=2e5+7;
inline int mymax(int x,int y){return x>y?x:y;}
inline int mymin(int x,int y){return x<y?x:y;}
void solve(){
int n, m;
cin>>n>>m;
if(n%(m+1)==0) cout<<"second"<<endl;
else cout<<"first"<<endl;
return ;
}
signed main(){
int T;cin>>T;
while(T--) solve();
return 0;
}