将每项系数乘以原指数,并按降幂顺序输出导函数系数。
OJ: noi_openjudge
题目 ID: ch0105-38
难度:入门
标签:模拟数学数组python
日期: 2026-07-30 23:01
题意
给出多项式从最高次到常数项的系数,输出其导函数的系数;若导函数为零,输出 0。
思路
输入系数 C_n, C_{n-1}, ..., C_0 已按降幂排列。前
当原多项式次数为 0。
代码
Python代码
python
degree = int(input())
coefficients = list(map(int, input().split()))
if degree == 0:
print(0)
else:
derivative = [coefficient * power for coefficient, power in zip(coefficients, range(degree, 0, -1))]
print(*derivative)C++代码
cpp
#include <cstdio>
#include <cmath>
int main(){
int t,n,i,c;
t=1;
while(t--){
scanf("%d",&n);
for (i=n;i>=1;i--){
scanf("%d",&c);
c *= i;
printf("%d ",c);
}
scanf("%d",&c);
if( n == 0){
printf("0");
}
printf("\n");
}
return 0;
}复杂度
时间复杂度为
总结
按降幂输入时,用递减的指数序列与系数配对即可直接落实求导公式。