結果

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

ソースコード

diff #

def f(x):
    c = 0
    while x % 2 == 0:
        c += 1
        x //= 2
    return c


N = int(input())
c = []
while N != 1:
    if N % 2 == 0:
        N //= 2
        c.append('/')
    elif f(3*N+1) > f(3*N-1):
        N = 3*N+1
        c.append('+')
    else:
        N = 3*N-1
        c.append('-')
print(len(c))
print(''.join(c))
0