結果
問題 |
No.3112 Decrement or Mod Game
|
ユーザー |
|
提出日時 | 2025-04-18 22:37:44 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 947 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2025-04-18 22:37:48 |
合計ジャッジ時間 | 3,533 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 44 WA * 21 |
ソースコード
import sys def main(): A, B = map(int, sys.stdin.read().split()) # inv = whether we swapped A,B once initially (to ensure A>=B) inv = False if A < B: A, B = B, A inv = True turn = True # True means “the player who started on (A,B)” a, b = A, B while True: q, r = divmod(a, b) # If r==0, the current player can do a % b → 0 and win. # If q>1, the current player can repeat the mod move enough times # to force the same win. if r == 0 or q > 1: result = turn break # Otherwise q==1: the only legal “mod” move is a→r, which swaps piles # and hands the turn to the opponent. a, b = b, r turn = not turn # If we did an initial swap, flip the result back if inv: result = not result sys.stdout.write("Alice\n" if result else "Bob\n") if __name__ == "__main__": main()