結果

問題 No.153 石の山
ユーザー satama6satama6
提出日時 2022-10-19 02:17:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 487 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 71,464 KB
最終ジャッジ日時 2023-09-11 17:40:00
合計ジャッジ時間 4,017 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,392 KB
testcase_01 AC 72 ms
71,448 KB
testcase_02 AC 73 ms
71,256 KB
testcase_03 AC 72 ms
71,248 KB
testcase_04 AC 72 ms
71,308 KB
testcase_05 AC 74 ms
71,296 KB
testcase_06 AC 72 ms
71,352 KB
testcase_07 AC 74 ms
71,068 KB
testcase_08 AC 73 ms
71,436 KB
testcase_09 AC 75 ms
71,256 KB
testcase_10 AC 72 ms
71,292 KB
testcase_11 AC 72 ms
71,224 KB
testcase_12 AC 71 ms
71,208 KB
testcase_13 AC 72 ms
71,404 KB
testcase_14 AC 73 ms
71,288 KB
testcase_15 AC 72 ms
71,252 KB
testcase_16 WA -
testcase_17 AC 71 ms
71,236 KB
testcase_18 AC 72 ms
71,280 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 72 ms
71,296 KB
testcase_22 AC 73 ms
71,208 KB
testcase_23 AC 73 ms
71,352 KB
testcase_24 AC 72 ms
71,316 KB
testcase_25 AC 73 ms
71,064 KB
testcase_26 AC 72 ms
71,444 KB
testcase_27 WA -
testcase_28 AC 72 ms
71,256 KB
testcase_29 WA -
testcase_30 AC 71 ms
71,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

grundy = [0] * (101)
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