結果

問題 No.153 石の山
ユーザー rlangevinrlangevin
提出日時 2023-07-12 12:04:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 5,000 ms
コード長 397 bytes
コンパイル時間 1,100 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 72,592 KB
最終ジャッジ日時 2023-10-12 02:13:22
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
72,088 KB
testcase_01 AC 110 ms
72,332 KB
testcase_02 AC 112 ms
72,088 KB
testcase_03 AC 115 ms
72,424 KB
testcase_04 AC 114 ms
72,212 KB
testcase_05 AC 113 ms
72,228 KB
testcase_06 AC 110 ms
72,504 KB
testcase_07 AC 113 ms
72,300 KB
testcase_08 AC 109 ms
72,312 KB
testcase_09 AC 109 ms
72,152 KB
testcase_10 AC 111 ms
72,392 KB
testcase_11 AC 110 ms
72,312 KB
testcase_12 AC 112 ms
72,324 KB
testcase_13 AC 111 ms
72,320 KB
testcase_14 AC 110 ms
72,164 KB
testcase_15 AC 112 ms
72,268 KB
testcase_16 AC 112 ms
72,024 KB
testcase_17 AC 112 ms
72,324 KB
testcase_18 AC 111 ms
72,268 KB
testcase_19 AC 111 ms
72,228 KB
testcase_20 AC 113 ms
72,256 KB
testcase_21 AC 112 ms
72,320 KB
testcase_22 AC 111 ms
72,260 KB
testcase_23 AC 111 ms
72,088 KB
testcase_24 AC 113 ms
72,084 KB
testcase_25 AC 114 ms
72,268 KB
testcase_26 AC 111 ms
72,316 KB
testcase_27 AC 112 ms
72,144 KB
testcase_28 AC 108 ms
72,592 KB
testcase_29 AC 110 ms
72,088 KB
testcase_30 AC 111 ms
72,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
from functools import lru_cache

@lru_cache(maxsize=None)
def f(n):
    if n == 1:
        return 0
    S = set()
    S.add(f(n//2)^f((n+1)//2))
    if n >= 3:
        S.add(f(n//3)^f((n+1)//3)^f((n+2)//3))
    
    now = 0
    while True:
        if now not in S:
            return now
        now += 1

N = int(input())
print("A") if f(N) else print("B")
0