結果

問題 No.153 石の山
ユーザー brthyyjpbrthyyjp
提出日時 2021-03-31 00:49:14
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 751 bytes
コンパイル時間 1,428 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 80,220 KB
最終ジャッジ日時 2023-08-20 20:42:17
合計ジャッジ時間 5,492 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,272 KB
testcase_01 AC 77 ms
71,208 KB
testcase_02 AC 77 ms
70,948 KB
testcase_03 AC 78 ms
71,176 KB
testcase_04 AC 78 ms
71,376 KB
testcase_05 AC 79 ms
71,268 KB
testcase_06 AC 79 ms
71,128 KB
testcase_07 AC 78 ms
71,280 KB
testcase_08 AC 79 ms
71,316 KB
testcase_09 AC 76 ms
70,904 KB
testcase_10 AC 78 ms
71,444 KB
testcase_11 AC 77 ms
71,140 KB
testcase_12 AC 80 ms
71,140 KB
testcase_13 AC 79 ms
71,300 KB
testcase_14 AC 80 ms
71,272 KB
testcase_15 AC 79 ms
71,268 KB
testcase_16 RE -
testcase_17 AC 79 ms
71,208 KB
testcase_18 AC 80 ms
71,068 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 76 ms
71,312 KB
testcase_22 AC 78 ms
71,324 KB
testcase_23 AC 77 ms
71,272 KB
testcase_24 AC 79 ms
71,464 KB
testcase_25 AC 77 ms
71,140 KB
testcase_26 AC 79 ms
70,960 KB
testcase_27 RE -
testcase_28 AC 78 ms
71,512 KB
testcase_29 RE -
testcase_30 AC 76 ms
71,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 1:
    print('B')
    exit()
grundy = [-1]*(n+1)
grundy[0] = 0
grundy[1] = 0
for i in range(2, n+1):
    S = set()
    if i%2 == 0:
        g = grundy[i//2]^grundy[i//2]
        S.add(g)
    else:
        g = grundy[(i-1)//2]^grundy[(i-1)//2+1]
        S.add(g)
    if i%3 == 0:
        g = grundy[i//3]^grundy[i//3]^grundy[i//3]
        S.add(g)
    elif i%3 == 1:
        g = grundy[(i-1)//3]^grundy[(i-1)//3]^grundy[(i-1)//3+1]
        S.add(g)
    else:
        g = grundy[(i-1)//3]^grundy[(i-1)//3+1]^grundy[(i-1)//3+1]
        S.add(g)
    g = 0
    while True:
        if g not in S:
            break
        else:
            g += 1
    grundy[i] = g
#print(grundy)
if grundy[n]:
    print('A')
else:
    print8('B')
0