This time, you are supposed to find 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_模拟 where 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_高精度_02 and 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_ios_03 are two polynomials.

Input Specification:
Each input file contains one test case. Each case occupies 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_i++_04 lines, and each line contains the information of a polynomial:

【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_高精度_05

where 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_高精度_06 is the number of nonzero terms in the polynomial, 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_i++_07 and 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_高精度_08 are the exponents and coefficients, respectively. It is given that 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_#include_09.

Output Specification:
For each test case you should output the product of 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_高精度_02 and 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_ios_03 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 【PAT (Advanced Level) Practice】1009 Product of Polynomials (25 分)_ios_12 decimal place.

Sample Input:

2 1 2.4 0 3.2
2 2 1.5 1 0.5

Sample Output:

3 3 3.6 2 6.0 1 1.6

#include<iostream>

using namespace std;

const int N = 1010;

double a[N], b[N], c[N*2];

void input(double a[]){

int k;
cin >> k;
while(k--){

int n; double v;
cin >> n >> v;
a[n] = v;
}
}

int main(){

input(a);
input(b);

for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
c[i + j] += a[i] * b[j];

int k = 0;
for(int i = 0; i < N * 2; i++)
if(c[i])
k++;

cout << k;
for(int i = 2 * N - 1; i >= 0; i--)
if(c[i])
printf(" %d %.1lf", i, c[i]);

return 0;
}