結果

問題 No.2426 Select Plus or Minus
コンテスト
ユーザー Cecil
提出日時 2023-08-18 22:10:05
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 882 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 758 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 75,644 KB
最終ジャッジ日時 2026-05-22 09:49:30
合計ジャッジ時間 9,113 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict as dd
import sys
sys.setrecursionlimit(10 ** 4)

n = int(input())

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

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