結果

問題 No.153 石の山
ユーザー 👑 KazunKazun
提出日時 2022-02-16 03:37:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 615 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 71,452 KB
最終ジャッジ日時 2023-09-11 17:06:42
合計ジャッジ時間 3,922 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,340 KB
testcase_01 AC 70 ms
71,292 KB
testcase_02 AC 72 ms
71,252 KB
testcase_03 AC 71 ms
71,240 KB
testcase_04 AC 72 ms
71,340 KB
testcase_05 AC 69 ms
71,132 KB
testcase_06 AC 71 ms
71,240 KB
testcase_07 AC 72 ms
71,052 KB
testcase_08 AC 70 ms
70,864 KB
testcase_09 AC 72 ms
70,860 KB
testcase_10 AC 73 ms
71,392 KB
testcase_11 AC 72 ms
71,296 KB
testcase_12 AC 72 ms
71,420 KB
testcase_13 AC 73 ms
71,444 KB
testcase_14 AC 72 ms
70,860 KB
testcase_15 AC 73 ms
71,400 KB
testcase_16 AC 73 ms
71,224 KB
testcase_17 AC 69 ms
71,340 KB
testcase_18 AC 72 ms
71,272 KB
testcase_19 AC 72 ms
71,368 KB
testcase_20 AC 72 ms
71,408 KB
testcase_21 AC 72 ms
71,324 KB
testcase_22 AC 72 ms
71,256 KB
testcase_23 AC 71 ms
71,304 KB
testcase_24 AC 72 ms
71,368 KB
testcase_25 AC 70 ms
71,452 KB
testcase_26 AC 69 ms
71,240 KB
testcase_27 AC 69 ms
71,236 KB
testcase_28 AC 70 ms
71,232 KB
testcase_29 AC 69 ms
71,256 KB
testcase_30 AC 71 ms
71,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mex(S):
    x=0
    while x in S:
        x+=1
    return x
#==================================================
N=int(input())

Grundy=[0]*(N+1)
for k in range(2,N+1):
    S=set()
    if k>=2:
        p=k//2
        if k%2==0:
            S.add(Grundy[p]^Grundy[p])
        else:
            S.add(Grundy[p]^Grundy[p+1])
    if k>=3:
        q=k//3
        if k%3==0:
            S.add(Grundy[q]^Grundy[q]^Grundy[q])
        elif k%3==1:
            S.add(Grundy[q]^Grundy[q]^Grundy[q+1])
        else:
            S.add(Grundy[q]^Grundy[q+1]^Grundy[q+1])
    Grundy[k]=mex(S)

print("A" if Grundy[N] else "B")
0