結果

問題 No.2426 Select Plus or Minus
ユーザー hato336
提出日時 2023-08-18 21:35:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-11-28 06:01:24
合計ジャッジ時間 3,335 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
check = 0

for i in range(100):
    m = n
    ans = 0
    l = []
    check = i
    while m != 1:
        if m >= 10**18:
            check = 1
            break
        ans += 1
        if m % 2 == 0:
            m //= 2
            l.append('/')
        else:
            if check:
                m = 3*m-1
                l.append('-')
                check -= 1
                continue
            m = 3*m+1
            l.append('+')
    if m == 1:
        check = 0
    if check >= 1:
        continue
    else:
        print(ans)
        print(''.join(l))
        break
0