結果

問題 No.153 石の山
ユーザー satama6satama6
提出日時 2022-10-19 02:16:32
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 487 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 79,300 KB
最終ジャッジ日時 2023-09-11 17:39:17
合計ジャッジ時間 4,493 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,220 KB
testcase_01 RE -
testcase_02 AC 80 ms
71,344 KB
testcase_03 AC 74 ms
71,192 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 75 ms
71,156 KB
testcase_07 AC 76 ms
71,080 KB
testcase_08 AC 78 ms
71,428 KB
testcase_09 AC 76 ms
71,320 KB
testcase_10 AC 76 ms
71,424 KB
testcase_11 AC 77 ms
71,160 KB
testcase_12 AC 77 ms
71,224 KB
testcase_13 AC 75 ms
71,160 KB
testcase_14 AC 74 ms
71,432 KB
testcase_15 AC 76 ms
71,052 KB
testcase_16 WA -
testcase_17 AC 77 ms
71,420 KB
testcase_18 AC 76 ms
71,156 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 75 ms
71,320 KB
testcase_22 AC 75 ms
71,152 KB
testcase_23 AC 74 ms
70,968 KB
testcase_24 AC 77 ms
71,260 KB
testcase_25 AC 77 ms
70,912 KB
testcase_26 AC 76 ms
71,292 KB
testcase_27 WA -
testcase_28 AC 75 ms
71,256 KB
testcase_29 WA -
testcase_30 AC 75 ms
71,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

grundy = [0] * (N+1)
base = {0, 1, 2}

grundy[2] = 1

for i in range(3, N+1):
    tmp = set()
    if i & 1:
        tmp.add(grundy[i//2] ^ grundy[i//2 + 1])
    else:
        tmp.add(0)
    
    if i % 3 == 0:
        tmp.add(grundy[i//3])
    elif i % 3 == 1:
        tmp.add(grundy[i//3 + 1])
    else:
        tmp.add(grundy[i//3] ^ grundy[i//3 + 1] ^ grundy[i//3 + 2])
    
    grundy[i] = (base - tmp).pop()


if grundy[N] == 0:
    print('B')
else:
    print('A')
0