题目:
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
1 1 Adrien
9 3 Adrien
题意:有n个石子,标号为1到n,在每一次的移动中,移动【1,k】连续的石子,当石子不能移动时为输
思路:当n==0时,Ad必输;
当n!=0时, 当k>=n时,Ad可以直接拿走所有的石子
当n为奇数时,Ad可以拿走中间的石子,然后Au拿多少,Ad拿多少,Ad赢;
当n为偶数时,Ad可以拿走中间的两个,然后Au拿多少,Ad拿多少,Ad赢(当k为1时,Ad必输)
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
int flag;
if(k>=n&&n!=0) flag=1;
else{
if(n==0) flag=2;
if(n%2==1){
flag=1;
}
if(n%2==0&&n!=0){
if(k==1){
flag=2;
}
else
flag=1;
}
}
if(flag==1)
printf("Adrien\n");
else {
printf("Austin\n");
}
}