題意:一堆石頭有N個,兩個人輪流取,每人只能取1-K個石頭,且取的石子必須是連續的K個,問誰贏?
分析:
1、K==1時,只與石子N的奇偶性有關,N爲奇數先手贏,N爲偶數後手贏。
2、N==0時,後手贏。
3、K>=2時,由於必須拿連續的K個,所以先手是有必勝策略的:即從石子最中間取走1或2顆石頭,將石頭分成數目相等的兩堆,這樣無論後手怎麼取,先手只需在剩下的那堆石頭模仿後手操作,就能保證必贏。
代碼如下:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
typedef long long ll;
int N,K;
int main()
{
ios::sync_with_stdio(false);
cin>>N>>K;
if(N==0){
cout<<"Austin"<<endl;
return 0;
}
if(K==1){
if(N%2)
cout<<"Adrien"<<endl;
else
cout<<"Austin"<<endl;
return 0;
}
if(N<=K){
cout<<"Adrien"<<endl;
return 0;
}
if(K>=2)
cout<<"Adrien"<<endl;
return 0;
}