結果

問題 No.153 石の山
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-12-29 23:06:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 61,560 KB
最終ジャッジ日時 2023-12-29 23:06:20
合計ジャッジ時間 2,936 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
61,560 KB
testcase_01 AC 49 ms
61,560 KB
testcase_02 AC 49 ms
61,560 KB
testcase_03 AC 48 ms
61,560 KB
testcase_04 AC 49 ms
61,560 KB
testcase_05 AC 49 ms
61,560 KB
testcase_06 AC 49 ms
61,560 KB
testcase_07 AC 49 ms
61,560 KB
testcase_08 AC 51 ms
61,560 KB
testcase_09 AC 49 ms
61,560 KB
testcase_10 AC 49 ms
61,560 KB
testcase_11 WA -
testcase_12 AC 49 ms
61,560 KB
testcase_13 AC 49 ms
61,560 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 49 ms
61,560 KB
testcase_17 AC 50 ms
61,560 KB
testcase_18 AC 49 ms
61,560 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 50 ms
61,560 KB
testcase_22 AC 49 ms
61,540 KB
testcase_23 AC 49 ms
61,560 KB
testcase_24 AC 49 ms
61,560 KB
testcase_25 AC 49 ms
61,560 KB
testcase_26 AC 50 ms
61,560 KB
testcase_27 WA -
testcase_28 AC 49 ms
61,560 KB
testcase_29 WA -
testcase_30 AC 49 ms
61,560 KB
権限があれば一括ダウンロードができます

ソースコード

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