結果

問題 No.2766 Delicious Multiply Spice
コンテスト
ユーザー n_na
提出日時 2024-06-01 00:03:28
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 566 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 191 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 765,996 KB
最終ジャッジ日時 2026-05-27 20:10:51
合計ジャッジ時間 9,298 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 17 TLE * 3 MLE * 2 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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