参考博客:http://blog.csdn.net/sun897949163/article/details/50609070
特判一下m=1的情况,然后m!=1时,无论对手取多少,我只要取的让这条链分成两个相同个数的子链就行了(之后按巴什博弈来处理),当然,如果先手能一次取完,那就后手必输
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-9; const int N=1000000+10,maxn=1234567,inf=11111; int main() { ios::sync_with_stdio(false); cin.tie(0); int t,n,m,cnt=0; cin>>t; while(t--){ cin>>n>>m; if(m==1) { if(n%2==1)cout<<"Case "<<++cnt<<": first"<<endl; else cout<<"Case "<<++cnt<<": second"<<endl; continue; } if(n<=m)cout<<"Case "<<++cnt<<": first"<<endl; else cout<<"Case "<<++cnt<<": second"<<endl; } return 0; }