結果

問題 No.2426 Select Plus or Minus
コンテスト
ユーザー miya145592
提出日時 2023-08-18 22:28:59
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 26 ms / 2,000 ms
+ 61µs
コード長 346 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 321 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 54,656 KB
最終ジャッジ日時 2026-10-01 08:08:35
合計ジャッジ時間 3,447 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
now = N
ans = []
while now>1:
    if now%2==0:
        ans.append("/")
        now//=2
    else:
        if (3*now+1)%4==0:
            ans.append("+")
            now = 3*now+1
        else:
            ans.append("-")
            now = 3*now-1
    assert(now<=10**18)
assert(len(ans)<=10000)
print(len(ans))
print("".join(ans))
0