結果

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

ソースコード

diff #

import sys


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

    ans = []
    while N > 1:
        if N % 2:
            n = N * 3
            if bin(n - 1).count("1") == 1:
                N = n - 1
                ans.append("-")
            else:
                N = n + 1
                ans.append("+")
        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