← 返回题库
初级

一元多项式求导

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve(poly):
    result = []
    for t in str(poly).split(";"):
        parts = t.split(",")
        coef, exp = int(parts[0]), int(parts[1])
        new_coef = coef * exp
        new_exp = exp - 1 if exp > 0 else 0
        result.append(str(new_coef) + " " + str(new_exp))
    print(" ".join(result))

示例

输入
4,3;-5,2;6,1;0,0
期望输出
12 2 -10 1 6 0 0 0
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码