結果
問題 |
No.153 石の山
|
ユーザー |
|
提出日時 | 2023-11-23 14:19:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 100 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-26 08:07:33 |
合計ジャッジ時間 | 1,924 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
from sys import setrecursionlimit setrecursionlimit(10**8) N = int(input()) dp = [0] * (N + 1) def rec(m): if m == 1: return 0 tmp = set() xor = rec(m // 2) ^ rec((m + 1) // 2) tmp.add(xor) if m >= 3: xor = rec(m // 3) ^ rec((m + 1) // 3) ^ rec((m + 2) // 3) tmp.add(xor) mex = 0 while 1: if mex not in tmp: break mex += 1 dp[m] = mex return mex ans = "A" if rec(N) else "B" print(ans)