2018年ACM-ICPC区域赛(南京)A.Adrien and Austin

2018年ACM-ICPC区域赛(南京)A.Adrien and Austin

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 ≤ 1 0 6 ) (0 \leq N \leq 10^6) (0N106)

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

大意

Adrien和Austin在玩游戏,一共有n个石头,Adrien和Austin轮流取石头,每个人只能取1到k个连续的石头,Adrien先取。求最后一块石子的人

思路

博弈论
k=1的时候,很明显和n的奇偶有关
当k>1时,Adrien可以把这n个石子分成两部分(n为奇数时,取中间的1个,n为偶数时,取中间的2个),接下来,Austin怎么取,Adrien就学Austin,在另一部分取,这样这样总能保证Adrien有石子取,最后,Austin显然取不到石子

代码

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define ll long long
#define ull unsigned long long
#define pii std::pair
#define op                            \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);

const int INF = 0x3f3f3f3f;
const int maxn = (500 + 5);
const int mod = (1000000007);

int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    if(n==0) printf("Austin\n");
    else if(k==1)
    {
        if(n%2) printf("Adrien\n");
        else printf("Austin\n");
    }
    else printf("Adrien\n");
    return 0;
}

你可能感兴趣的:(2018年ACM-ICPC区域赛(南京)A.Adrien and Austin)