結果

問題 No.153 石の山
ユーザー satama6satama6
提出日時 2022-10-19 02:14:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 71,472 KB
最終ジャッジ日時 2023-09-11 17:37:36
合計ジャッジ時間 4,430 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,996 KB
testcase_01 AC 72 ms
71,012 KB
testcase_02 AC 71 ms
71,472 KB
testcase_03 AC 70 ms
71,148 KB
testcase_04 AC 68 ms
71,076 KB
testcase_05 AC 73 ms
71,012 KB
testcase_06 AC 71 ms
71,092 KB
testcase_07 AC 70 ms
71,016 KB
testcase_08 AC 70 ms
71,132 KB
testcase_09 AC 69 ms
71,088 KB
testcase_10 AC 68 ms
71,280 KB
testcase_11 AC 68 ms
71,368 KB
testcase_12 AC 68 ms
71,284 KB
testcase_13 AC 68 ms
71,140 KB
testcase_14 AC 69 ms
71,072 KB
testcase_15 AC 67 ms
71,140 KB
testcase_16 WA -
testcase_17 AC 69 ms
71,368 KB
testcase_18 AC 69 ms
71,012 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 71 ms
71,384 KB
testcase_22 AC 74 ms
71,076 KB
testcase_23 AC 69 ms
71,148 KB
testcase_24 AC 71 ms
71,340 KB
testcase_25 AC 68 ms
71,008 KB
testcase_26 AC 70 ms
71,128 KB
testcase_27 WA -
testcase_28 AC 70 ms
71,212 KB
testcase_29 WA -
testcase_30 AC 69 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

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

for i in range(2, 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