結果

問題 No.153 石の山
ユーザー Navier_Boltzmann
提出日時 2023-12-29 23:06:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 63,516 KB
最終ジャッジ日時 2024-09-27 16:24:17
合計ジャッジ時間 3,464 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math,time,random
input = sys.stdin.readline

N = int(input())


mem = [-1]*(N+1)
def f(x):
    if mem[x]!=-1:
        return mem[x]
    if x%2==0:
        mem[x] = 1
        return 1
    
    if x==1:
        mem[x] = 0
        return mem[x]
    
    X = []
    n = x//2
    if n%2==0:
        X.append(f(n+1))
    else:
        X.append(f(n))

    n = x//3
    if x%3==0:
        X.append(f(n))
    elif x%3==1:
        X.append(f(n+1))
    else:
        X.append(f(n))
    mem[x] = 1 - min(X)
    return mem[x]

if f(N):
    print('A')
else:
    print('B')
0