結果
| 問題 |
No.2426 Select Plus or Minus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-19 00:42:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,066 bytes |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-11-28 12:49:07 |
| 合計ジャッジ時間 | 4,132 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 WA * 5 |
ソースコード
from collections import defaultdict
import sys
def main():
sys.setrecursionlimit(100000)
input = lambda: sys.stdin.readline()[:-1]
N = int(input())
num = defaultdict(bool)
ans = []
while N > 1:
if N % 2:
n = N * 3
if bin(n - 1).count("1") == 1 and not num[n - 1]:
N = n - 1
ans.append("-")
num[n - 1] = True
elif bin(n + 1).count("1") == 1 and not num[n + 1]:
N = n + 1
ans.append("+")
num[n + 1] = True
elif not num[n - 1]:
N = n - 1
ans.append("-")
num[n - 1] = True
else:
N = n + 1
ans.append("+")
num[n + 1] = True
else:
N //= 2
ans.append("/")
print(len(ans))
print("".join(ans))
if not __debug__:
f = open(sys.argv[1], "r")
sys.stdin = f
try:
sys.set_int_max_str_digits(100000)
except AttributeError:
pass
main()