No.2103 ±1s Game
タグ : / 解いたユーザー数 80
作問者 :
Sumitacchan
/ テスター :
👑
hitonanode
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もしくは右上の雲マークをクリックしてアカウントを作成してください。