結果

問題 No.2426 Select Plus or Minus
ユーザー Cecil
提出日時 2023-08-18 21:48:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-11-28 06:35:01
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 35 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as dd
import sys
sys.setrecursionlimit(1 << 20)

n = int(input())

dic = dd(lambda:"")
ans = list()

def dfs(v):
    if v == 1:
        ans.append(dic[v])
    if v % 2 == 0:
        dic[v//2] = dic[v] + "/"
        v //= 2
        dfs(v)
    else:
        if dic[3*v+1] == "":
            dic[3*v+1] = dic[v] + "+"
            dfs(3*v+1)
        elif dic[3*v-1] == "":
            dic[3*v-1] = dic[v] + "-"
            dfs(3*v-1)
m = n
dfs(m)
#print(ans)
print(len(ans[0]))
print(ans[0])
0