結果
問題 |
No.2426 Select Plus or Minus
|
ユーザー |
👑 ![]() |
提出日時 | 2023-08-18 22:10:47 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 398 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-11-28 07:35:16 |
合計ジャッジ時間 | 5,877 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 WA * 5 |
ソースコード
""" 奇数は 1 -> 2 or 4 3 -> 8 or """ import sys from sys import stdin N = int(stdin.readline()) ans = [] s = set() while N != 1: s.add(N) if N % 2 == 0: ans.append("/") N //= 2 elif (3*N-1) % 2 == 0 and (3*N-1) not in s: ans.append("-") N = 3*N-1 else: ans.append("+") N = 3*N+1 print (len(ans)) print ("".join(ans))