1009 Product of Polynomials 发表于 2020-05-30 题目大意:求2个多项式A*B后的结果。 1234567891011121314151617181920212223242526272829303132333435#include <bits/stdc++.h>using namespace std;int main() { int k1, k2, cnt = 0, exp; double coe, arr[1001] = {0.0}, ans[2001] = {0.0}; scanf("%d", &k1); for (int i = 0; i < k1; i++) { scanf("%d %lf", &exp, &coe); arr[exp] += coe; } scanf("%d", &k2); for (int i = 0; i < k2; i++) { scanf("%d %lf", &exp, &coe); for (int j = 0; j <= 1000; j++) { ans[j + exp] += arr[j] * coe; } } for (int i = 2000; i >= 0; i--) { if (ans[i]) cnt++; } printf("%d", cnt); for (int i = 2000; i >= 0; i--) { if (ans[i]) printf(" %d %.1f", i, ans[i]); } return 0;}2 1 2.4 0 3.22 2 1.5 1 0.53 3 3.6 2 6.0 1 1.6