PTA一元多项式求导 (25分)

    科技2023-12-27  100

    每个人都有崩溃的时候,就看你的抗压能力到底有多强,如果你的抗压能力强,有办法可以支撑到你能面对并且解决这些困难的话,你就没有问题。                                                                          ----喻言

    设计函数求一元多项式的导数。(注:x​n​​(n为整数)的一阶导数为nx​n−1​​。)

    输入格式:

    以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过 1000 的整数)。数字间以空格分隔。

    输出格式:

    以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。注意“零多项式”的指数和系数都是 0,但是表示为 0 0。

    输入样例:

    3 4 -5 2 6 1 -2 0

    输出样例:

    12 3 -10 1 6 0 #include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cstring> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <vector> #include <ctime> #include <cctype> #include <bitset> #include <utility> #include <sstream> #include <complex> #include <iomanip> #include <numeric> #include<unordered_set> #include <climits>//INT_maxnn //#include<bits/stdc++.h> #define PP pair<ll,int> #define inf 0x3f3f3f3f #define INF 0x7fffffff; #define llinf 0x3f3f3f3f3f3f3f3fll #define dinf 1000000000000.0 #define PI 3.1415926 #define LL unsigned int #define wc 1e-8 typedef long long ll; using namespace std; int a,b,fg=0; int main(){ while (cin>>a>>b){ if (b!=0){ if (fg==1) cout<<" "; cout<<a*b<<" "<<b-1; fg=1; } } if(fg==0) cout<<"0 0"; return 0; }

     

    Processed: 0.016, SQL: 8