1009. Product of Polynomials (25)
来源:互联网 发布:js得到radio的值 编辑:程序博客网 时间:2024/05/09 00:23
#include<iostream>#include<stdio.h>using namespace std;int a1[1200], a2[1200];double b1[1210];double b2[1210];double b3[2010];int main(){int k;cin >> k;for (int i = 0; i<k; i++){int x;cin >> x;a1[x] = x;double y;cin >> y;b1[x] += y;}cin >> k;for (int i = 0; i<k; i++){int x;cin >> x;a2[x] = x;double y;cin >> y;b2[x] += y;}for (int j = 0; j<1201; j++){if (b1[j])for (int i = 0; i<1201; i++){if (b2[i]){int h = a1[j] + a2[i];//cout<<a1[j]<<"----"<<a2[i]<<endl;b3[h] = b1[j] * b2[i] + b3[h];//cout<<b1[i]<<"----"<<b2[j]<<endl;//cout<<b3[h]<<endl;}}}int num = 0;for (int i = 2010; i >= 0; i--){if (b3[i]) num++;}cout << num;for (int i = 2010; i >= 0; i--){if (b3[i]) printf(" %d %.1f", i, b3[i]);}cout << endl;return 0;}
时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
This time, you are supposed to find A*B where A and B are two polynomials.
Input Specification:
Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 ... NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, ..., K) are the exponents and coefficients, respectively. It is given that 1 <= K <= 10, 0 <= NK < ... < N2 < N1 <=1000.
Output Specification:
For each test case you should output the product of A and B in one line, with the same format as the input. Notice that there must be NO extra space at the end of each line. Please be accurate up to 1 decimal place.
Sample Input2 1 2.4 0 3.22 2 1.5 1 0.5Sample Output
3 3 3.6 2 6.0 1 1.6
0 0
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- caffe中batch_norm层代码详细注解
- 【转】Qt之文件操作 QFile
- java的四种引用,强弱软虚,用到的场景 (r)
- Java与算法之(8) - 堆排序
- ubuntu中安装android sdk
- 1009. Product of Polynomials (25)
- spring Aop拦截controller方法
- 手机网页中,长按会触发系统事件,禁止系统事件
- 在caffe中添加新的层
- 应用内切换语言
- AysncTask实现异步下载图片
- Ubuntu 16.04 + GTK780 + opencv 安装配置
- Android性能优化之UI渲染优化
- 小数精度。