結果
問題 |
No.2426 Select Plus or Minus
|
ユーザー |
![]() |
提出日時 | 2023-08-19 19:05:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 481 bytes |
コンパイル時間 | 93 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-29 14:06:15 |
合計ジャッジ時間 | 3,333 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
N = int(input()) ans = [] while N != 1: if N % 2 == 0: N //= 2 ans += "/" else: Np, cp = N * 3 + 1, 0 Nm, cm = N * 3 - 1, 0 while Np % 2 == 0: Np //= 2 cp += 1 while Nm % 2 == 0: Nm //= 2 cm += 1 if cp > cm: N = Np ans += "+" + "/" * cp else: N = Nm ans += "-" + "/" * cm print(len(ans)) print(*ans, sep="")