結果
問題 |
No.153 石の山
|
ユーザー |
|
提出日時 | 2023-11-23 14:13:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-26 08:07:22 |
合計ジャッジ時間 | 2,305 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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() if m % 2 == 0: xor = rec(m // 2) ^ rec(m // 2) else: xor = rec(m // 2) ^ rec((m // 2) + 1) tmp.add(xor) if m >= 3: if m % 3 == 0: xor = rec(m // 3) ^ rec(m // 3) ^ rec(m // 3) elif m % 3 == 1: xor = rec(m // 3) ^ rec(m // 3) ^ rec((m // 3) + 1) elif m % 3 == 2: xor = rec(m // 3) ^ rec((m // 3) + 1) ^ rec((m // 3) + 1) 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)