問題一覧 > 通常問題

No.582 Candy Box 3

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 191
作問者 : nmnmnmnmnmnmnm / テスター : mai
お気に入りにしたユーザー ProblemId : 1296 / 自分の提出
問題文最終更新日: 2026-06-26 06:07:04
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 175 (順位表) の他の問題:

Problem Statement

There are $N$ boxes that can hold candies.
The $i$-th box contains $C_i$ candies.

A and B play a game with the following rules.

・A moves first, and A and B take turns alternately.
・In one move, A chooses any one box of candies and takes 1 candy from it.
・In one move, B chooses any one box of candies and takes 1 or 2 candies from it.
・Neither A nor B may pass their move.
・The player who cannot take a candy because all the boxes are empty loses.
・Both A and B play optimally to win.

Given the initial state, determine who wins in the end.

Input

$N$
$C_1$ $C_2$ $\dots$ $C_N$

$N$ is the number of candy boxes. $1 \le N\le 150$.
$C_i$ is the number of candies initially in the $i$-th box. $0 \le C_i\le 1000000000=10^9$.

Output

Print "A" if A wins, and "B" if B wins.
Print a newline at the end.

Sample

Sample 1
Input
2
1 2
Output
A

There are 2 candy boxes.
One box contains 1 candy.
The other box contains 2 candies.
A, moving first, takes 1 candy from the box containing 2 candies.
B takes 1 candy from either box.
A takes 1 candy from the box that still has a candy.
All the boxes are now empty, and B cannot take a candy.
Therefore, A wins.

Sample 2
Input
1
3
Output
B

There is 1 candy box.
The box contains 3 candies.
A takes 1 candy from the box.
B takes 2 candies from the box.
The box is now empty, and A cannot take a candy.
Therefore, B wins.

Sample 3
Input
5
1 1 2 4 0
Output
B

B wins.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。