#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
const int maxn = 1000 + 5;
typedef struct {
int exp;
float coef;
}node;
int main(void)
{
//freopen("in.txt", "r", stdin);
int k;
vector <node> p(10);
cin >> k;
for (int i = 0; i < k; i++)
{
cin >> p[i].exp >> p[i].coef;
}
int n;
cin >> n;
vector <float> ans(maxn << 1);
for (int i = 0; i < n; i++)
{
int e;
float c;
cin >> e >> c;
for (int i = 0; i < k; i++)
{
ans[e + p[i].exp] += c * p[i].coef;
}
}
int tot = 0;
for (int i = (maxn << 1) - 1; ~i; i--)
if (fabs(ans[i]) > 1e-2) tot++;
cout << tot;
for (int i = (maxn << 1) - 1; ~i; i--)
{
if (fabs(ans[i] - 0.0) > 1e-2) cout << " " << i << " " << setiosflags(ios::fixed) << setprecision(1) << ans[i];
}
return 0;
}
PAT(甲级) 1009 Product of Polynomials (简易模拟)
最新推荐文章于 2024-10-25 01:30:00 发布