結果

問題 No.153 石の山
ユーザー vwxyz
提出日時 2022-08-10 04:54:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-20 09:16:45
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
grundy=[None]*(N+1)
grundy[1]=0
for n in range(2,N+1):
    se=set()
    if n%2==0:
        se.add(0)
    else:
        se.add(grundy[n//2]^grundy[n//2+1])
    if n%3==0:
        se.add(grundy[n//3])
    elif n%3==1:
        se.add(grundy[n//3+1])
    else:
        se.add(grundy[n//3])
    x=0
    while x in se:
        x+=1
    grundy[n]=x
if grundy[N]:
    ans="A"
else:
    ans="B"
print(ans)
0