#include<iostream>
#include<iomanip>
using namespace std;
#define N 1000*1000+10
int NA, NB;
float A[N], B[N], C[N];
int main()
{
for (int i = 0; i <= 1000 * 1000; i++)
{
A[i] = B[i] = C[i] = 0;
}
cin >> NA;
for (int i = 1; i <= NA; i++)
{
float a;
int m;
cin >> m >> a;
A[m] = a;
}
cin >> NB;
for (int i = 1; i <= NB; i++)
{
float a;
int m;
cin >> m >> a;
B[m] = a;
}
for(int i=0;i<=1000;i++)
for (int j = 0; j <= 1000; j++)
{
int m;
float a;
m = i + j;
a = A[i] * B[j];
C[m] += a;
}
int sum = 0;
for (int i = 0; i <= 1000 * 1000; i++)
{
if (C[i] != 0)
sum++;
}
cout << sum;
for (int i = 1000 * 1000; i >= 0; i--)
{
if (C[i] != 0)
cout << ' ' << i << ' ' << fixed << setprecision(1) << C[i];
}
cout << endl;
system("pause");
return 0;
}
1009
最新推荐文章于 2022-09-04 10:19:03 发布