QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#9658. 素数ゲーム

Statistics

Alice と Bob はいつも互いにゲームをするのが好きで、今日は素数に関する新しいゲームを見つけました。

ゲームには 2 個の正整数 $x$ と $y$ があり、Alice と Bob が交互に手番を行います。各手番で、現在のプレイヤーは整数を一つ選んで $1$ を引くことができます($(x, y)$ を $(x - 1, y)$ または $(x, y - 1)$ にします)。次の条件のいずれかが満たされるとゲームが終了し、同時に勝者が決まります。

  • $x$ または $y$ が $K$ と等しいとき:Bob の勝ちです。
  • $x$ と $y$ が両方とも素数のとき:Alice の勝ちです。
  • 上の二つの条件が同時に満たされるとき:Bob の勝ちです。

$x, y, K$ と先手のプレイヤーが与えられます。二人とも最適にプレイするとき、最後にどちらが勝つか判定できますか?

入力

入力の最初の行には、テストケース数を表す整数 $T$ が含まれます。続く $T$ 行には、それぞれ一つのテストケースが含まれます。

各テストケースには、ちょうど一つの空白で区切られた 4 個の整数 $x, y, K$ と $w$ が含まれます。$x,y,K$ は上記のとおりです。Alice が先手なら $w = 0$、Bob が先手なら $w = 1$ です。

出力

各テストケースについて、1 行に Case x: name を出力してください。x は 1 から始まるテストケース番号で、name はゲームに勝つプレイヤーの名前です。

入出力例

入力 1

4
4 9 2 0
7 10 2 0
6 39 2 0
5 28 2 0

出力 1

Case 1: Alice
Case 2: Alice
Case 3: Alice
Case 4: Bob

注記

$1 \le T \le 100$

$2 \le x, y \le 10^6$

$2 \le K \le \min(x, y)$

$0 \le w \le 1$

テストケースの $90\%$ について:$\max(x, y) \le 1000$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.