Adrien and Austin are playing a game with rocks.
Initially, there are N rocks, indexed from 1 to N. In one move, the player chooses at least 1 and at most
K consecutively indexed rocks (all of them should not have been removed) and removes them from the
game.
Adrien always starts the game, and then Adrien and Austin take turns making moves. The player who is
unable to make a move (because all rocks are removed) loses.
Given N, K, find who is going to win the game (assuming they are smart and are playing optimally).
Input
The first line contains two integers N, K (0 ≤ N ≤ 106, 1 ≤ K ≤ 106).
Output
Print a name (“Adrien” or “Austin”, without the quotes) — the person who is going to win the game.
Examples
standard input standard output
1 1 Adrien
9 3 Adrien
思路:一开始我直接一手看错,然后把这道题目当作普通的巴什博弈,然后套公式n%(m+1)==0先手必赢,然后光荣WA,直接裂开。后来仔细读题之后才发现,题目中有连续二字,每个人只能取连续编号的石子,所以题目就完全不一样了。。。后来开始枚举,发现当n=0时先手必输,然后当k=1时,n为奇数先手必赢,n为偶数先手必输。k>1时,先手必赢。当然这不是正解,是猜出来的。后来我翻看了大佬的博客,发现当k>1时,我们必然可以把序列取成两份一样的,取中间,然后先手只要跟着对手取就永远不会没有东西取,必赢。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int flag=0;
if(k==1&&n%2==1)flag=1;
if(k>1)flag=1;
if(n==0)flag=0;
if(flag==1)printf("Adrien\n");
else printf("Austin\n");
return 0;
}