結果

問題 No.2766 Delicious Multiply Spice
ユーザー n_nan_na
提出日時 2024-06-01 00:03:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 566 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 701,580 KB
最終ジャッジ日時 2024-06-01 00:03:39
合計ジャッジ時間 10,302 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
61,852 KB
testcase_01 AC 41 ms
54,792 KB
testcase_02 AC 43 ms
54,548 KB
testcase_03 AC 41 ms
54,328 KB
testcase_04 AC 42 ms
54,124 KB
testcase_05 AC 44 ms
54,304 KB
testcase_06 AC 41 ms
54,916 KB
testcase_07 AC 41 ms
53,988 KB
testcase_08 AC 41 ms
54,852 KB
testcase_09 AC 41 ms
53,776 KB
testcase_10 AC 44 ms
54,812 KB
testcase_11 AC 43 ms
54,232 KB
testcase_12 AC 44 ms
54,848 KB
testcase_13 AC 57 ms
64,840 KB
testcase_14 AC 43 ms
54,852 KB
testcase_15 AC 41 ms
54,220 KB
testcase_16 AC 41 ms
55,320 KB
testcase_17 AC 42 ms
54,192 KB
testcase_18 AC 44 ms
53,944 KB
testcase_19 AC 73 ms
78,580 KB
testcase_20 AC 66 ms
73,392 KB
testcase_21 AC 624 ms
238,476 KB
testcase_22 AC 341 ms
189,824 KB
testcase_23 AC 263 ms
176,892 KB
testcase_24 AC 348 ms
191,024 KB
testcase_25 TLE -
testcase_26 MLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

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