結果

問題 No.2426 Select Plus or Minus
ユーザー GrayCoderGrayCoder
提出日時 2023-08-19 00:26:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-28 12:29:30
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys


def main():
    sys.setrecursionlimit(100000)
    input = lambda: sys.stdin.readline()[:-1]
    N = int(input())

    flag = defaultdict(bool)
    ans = []
    while N > 1:
        if N % 2:
            n = N * 3
            if flag[n - 1]:
                N = n + 1
                ans.append("+")
                flag[n + 1] = True
            else:
                N = n - 1
                ans.append("-")
                flag[n - 1] = True
        else:
            N //= 2
            ans.append("/")
    print(len(ans))
    print("".join(ans))


if not __debug__:
    f = open(sys.argv[1], "r")
    sys.stdin = f

try:
    sys.set_int_max_str_digits(100000)
except AttributeError:
    pass

main()
0