結果

問題 No.2766 Delicious Multiply Spice
ユーザー n_nan_na
提出日時 2024-06-01 00:03:28
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 566 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 875,632 KB
最終ジャッジ日時 2024-12-21 01:53:06
合計ジャッジ時間 46,972 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 MLE * 4
other AC * 8 TLE * 13 MLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N = int(input())

x = 1
deq = deque()
deq.append(1)
dct = dict()
dct[1] = 0

while deq:
    x2 = 2*x + 1
    if x2 <= N and x2 not in dct:
        dct[x2] = x
        deq.append(x2)
    x3 = 3*x + 1
    if x3 <= N and x3 not in dct:
        dct[x3] = x
        deq.append(x3)
    x = deq.popleft() 
    
ans = []
while True:
    if dct[N] == 0:
        break
    pre = dct[N]
    if 2*pre + 1 == N:
        ans.append("A")
    else:
        ans.append("B")
    N = pre
        
ans = list(reversed(ans))
ans = "".join(ans)

print(ans)
0