結果
| 問題 |
No.153 石の山
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2020-12-18 23:52:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| コード長 | 534 bytes |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-21 09:30:41 |
| 合計ジャッジ時間 | 2,289 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
from functools import lru_cache
@lru_cache(maxsize=None)
def grundy(x):
if x == 0 or x == 1:
return 0
if x == 2:
return 1
S = set()
if x >= 2:
a = x // 2
b = x - a
S.add(grundy(a) ^ grundy(b))
if x % 3 == 1:
S.add(grundy(x // 3 + 1))
else:
S.add(grundy(x // 3))
S = sorted(S)
for i, s in enumerate(S):
if i == s:
continue
return i
return i + 1
N = int(input())
if grundy(N):
print("A")
else:
print("B")
tktk_snsn