codeforces 282 D. Yet Another Number Game

更好的阅读体验

D. Yet Another Number Game

开启传送门

题目描述

Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!

Since you are so curious about Bitland, I’ll give you the chance of peeking at one of these games.

BitLGM and BitAryo are playing yet another of their crazy-looking genius-needed Bitlandish games. They’ve got a sequence of n n n non-negative integers a 1 ,   a 2 ,   . . . ,   a n a_1, a_2, ..., a_n a1,a2,...,an. The players make moves in turns. BitLGM moves first. Each player can and must do one of the two following actions in his turn:

  • Take one of the integers (we’ll denote it as a i a_i ai). Choose integer x x x ( 1   ≤   x   ≤   a i 1 \le x \le a_i 1xai). And then decrease a i a_i ai by x x x, that is, apply assignment: a i a_i ai =  a i a_i ai -  x x x.
  • Choose integer x x x ( 1 ≤ x ≤ m i n i = 1 n a i 1\le x \le min_{i=1}^n a_i 1xmini=1nai). And then decrease all a i a_i ai by x x x, that is, apply assignment: a i   =   a i   −   x a_i = a_i - x ai=aix, for all i i i.

The player who cannot make a move loses.

You’re given the initial sequence a 1 ,   a 2 ,   … ,   a n a_1, a_2, \dots, a_n a1,a2,,an. Determine who wins, if both players plays optimally well and if BitLGM and BitAryo start playing the described game in this sequence.

Input

The first line contains an integer n n n ( 1   ≤   n   ≤   3 1 \le n \le 3 1n3).

The next line contains n n n integers a 1 ,   a 2 ,   … ,   a n a_1, a_2, \dots, a_n a1,a2,,an ( 0   ≤   a i   <   300 0 \le a_i \lt 300 0ai<300).

Output

Write the name of the winner (provided that both players play optimally well). Either “BitLGM” or “BitAryo” (without the quotes).

Example

input1
2
1 1
output1
BitLGM
input2
2
1 2
output2
BitAryo
input3
3
1 2 1
output3
BitLGM

题意

两个人玩取石子游戏,按照如下规则取石子:

  1. 每次可以选择一堆去掉任意多个。
  2. 每次选择所有的堆,去掉任意多个(每堆去掉的数量相同)。

不能操作的人为负,BitLGM先手,BitAryo后手,问你谁必胜。

分析

注意到数据范围, 1 ≤ n ≤ 3 , 0 ≤ a i < 300 1\le n\le 3, 0\le a_i \lt 300 1n30ai<300

不难看出,这个可以转换为三个子问题。

  1. 只有一堆
  2. 只有两堆
  3. 有三堆。

下面分情况讨论。

只有一堆

不难发现,对于先手来说,我可以直接取走这一堆,所以只要 a 1 ≠ 0 a_1 \ne 0 a1=0 那么必然有先手必胜 。

只有两堆

不难想到的是,我们可以用一个二维数组来判定当前的胜负态,也即:定义 G ( i , j ) G(i, j) <

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zuhiul

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值