結果

問題 No.153 石の山
ユーザー 👑 rin204rin204
提出日時 2022-09-30 23:16:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 383 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 86,488 KB
実行使用メモリ 71,380 KB
最終ジャッジ日時 2023-08-24 16:49:09
合計ジャッジ時間 4,224 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,096 KB
testcase_01 AC 72 ms
71,204 KB
testcase_02 AC 71 ms
71,184 KB
testcase_03 AC 72 ms
70,944 KB
testcase_04 AC 72 ms
71,252 KB
testcase_05 AC 71 ms
71,304 KB
testcase_06 AC 72 ms
71,096 KB
testcase_07 AC 72 ms
71,096 KB
testcase_08 AC 72 ms
71,196 KB
testcase_09 AC 72 ms
71,288 KB
testcase_10 AC 71 ms
71,160 KB
testcase_11 AC 72 ms
70,944 KB
testcase_12 AC 73 ms
71,276 KB
testcase_13 AC 73 ms
71,280 KB
testcase_14 AC 71 ms
71,172 KB
testcase_15 AC 72 ms
71,100 KB
testcase_16 AC 72 ms
71,036 KB
testcase_17 AC 74 ms
71,184 KB
testcase_18 AC 72 ms
71,188 KB
testcase_19 AC 73 ms
71,172 KB
testcase_20 AC 71 ms
71,092 KB
testcase_21 AC 71 ms
71,184 KB
testcase_22 AC 72 ms
71,248 KB
testcase_23 AC 72 ms
71,168 KB
testcase_24 AC 71 ms
71,156 KB
testcase_25 AC 71 ms
71,344 KB
testcase_26 AC 71 ms
71,244 KB
testcase_27 AC 72 ms
71,256 KB
testcase_28 AC 72 ms
71,080 KB
testcase_29 AC 72 ms
71,380 KB
testcase_30 AC 71 ms
71,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

grundy = [0] * (n + 1)
grundy[1] = 0
for i in range(2, n + 1):
    a = i // 2
    b = (i + 1) // 2
    x = grundy[a] ^ grundy[b]

    a = i // 3
    b = (i + 1) // 3
    c = (i + 2) // 3
    y = grundy[a] ^ grundy[b] ^ grundy[c]

    mex = 0
    while mex == x or mex == y:
        mex += 1
    grundy[i] = mex
if grundy[n] == 0:
    print("B")
else:
    print("A")
0