本地题面缓存已迁移,解析内容待补充。
OJ: noi_openjudge
题目 ID: ch0113-39
难度:未知
标签:python
日期: 2026-07-30 23:01
题意
完整题面见同目录的 problem.md。
思路
代码
Python代码
python
degree = int(input())
coefficients = list(map(int, input().split()))
parts = []
for index, coefficient in enumerate(coefficients):
exponent = degree - index
if coefficient == 0:
continue
sign = "-" if coefficient < 0 else "+"
absolute = abs(coefficient)
if exponent == 0:
body = str(absolute)
elif exponent == 1:
body = ("" if absolute == 1 else str(absolute)) + "x"
else:
body = ("" if absolute == 1 else str(absolute)) + f"x^{exponent}"
parts.append((sign, body))
first_sign, first_body = parts[0]
print(("" if first_sign == "+" else "-") + first_body + "".join(sign + body for sign, body in parts[1:]))