The 43 rd ACM International Collegiate Programming Contest Adrien and Austin---小shi shi 给小天天的 Day1

Problem A. Adrien and Austin

Input file: standard input Output file: standard output 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 

题意:

有1~N个石子 , 俩人轮流拿 , 每次至少拿一个,最多连续K个石子。

这里一定要注意俩点 , 1,连续的石子。2,是1~K任意个连续的石子 , 而不是一个或K个连续的石子。

思路:

先手从该石子的中间取 , 将他们等分成俩半 , 这样不管后手取多少 , 先手都跟他取一样的一定能确保先手赢。

那么后手赢得情况只有 , N = 0 时 , 和 N为偶数且K = 1 时 , 其他就是先手赢了 , 因为若k>=2 时 , 可拿奇数个也能拿偶数个一定能保证等分。

代码:

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

 

你可能感兴趣的:(The 43 rd ACM International Collegiate Programming Contest Adrien and Austin---小shi shi 给小天天的 Day1)