問題一覧 > 通常問題

No.2103 ±1s Game

レベル : / AI推定難易度 : 1450 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 80
作問者 : Sumitacchan / テスター : 👑 hitonanode ygussany
お気に入りにしたユーザー ProblemId : 8461 / 自分の提出
問題文最終更新日: 2022-10-08 11:11:08
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 365 (順位表) の他の問題:

Problem Statement

There are $X$ cards with $+1$ written on them and $Y$ cards with $-1$ written on them.
Alice and Bob play a game using these $X+Y$ cards.

Starting with Alice, the two players alternately repeat the action of choosing $1$ card from the remaining cards and eating it.
The game ends as soon as exactly $K$ cards remain.
If the product of the numbers written on those $K$ cards is equal to $P$, Alice wins; otherwise, Bob wins.

Determine which player wins when both players play optimally.

Constraints

  • $1 \le X,Y \le 10^9$
  • $1 \le K \le X+Y-1$
  • $P=1$ or $P=-1$
  • All inputs are integers.

Input

The input is given from standard input in the following format.

$X\ \ Y\ \ K\ \ P$

Output

Print Alice if Alice wins, and Bob if Bob wins.

Sample

Sample 1
Input
2 2 3 1
Output
Alice

Suppose Alice first eats a $+1$ card. At that point exactly $K=3$ cards remain, so the game ends.
The remaining $3$ cards are $+1,-1,-1$, so their product is $+1\ (=P)$, and Alice wins.

Sample 2
Input
2 2 2 -1
Output
Bob

By the strategy of eating the same kind of card as Alice, Bob can make the remaining $K=2$ cards either $+1,+1$ or $-1,-1$.
Therefore, he can always make the product $+1\ (\ne P)$, so Bob has a winning strategy.

Sample 3
Input
9876 54 32 1
Output
Alice

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