#include<bits/stdc++.h>
using namespace std;
double a[2001] ={0.0};
map<int,double> mp1 ;
map<int ,double>mp2;
int main(){
int n ;
int exp ;
double cie;
cin>>n;
while(n--){
cin>>exp >>cie;
mp1[exp] = cie;
}
cin>>n;
while(n--){
cin>>exp >>cie;
mp2[exp] = cie;
}
int counter = 0;
for(map<int , double >::iterator it= mp1.begin() ; it != mp1.end() ; it++)
for(map<int , double >::iterator it1 = mp2.begin() ; it1 != mp2.end() ;it1++){
int exp1 = it->first + it1->first;
double cie1 = it->second * it1->second;
if(!a[exp1])
counter++;
a[exp1]+=cie1;
if(!a[exp1])
counter--;
}
cout<<counter;
for(int i = 2000; i >=0 ; i--){
if(a[i])
printf(" %d %0.1lf",i,a[i]);
}
}
1009 Product of Polynomials (25 分)
最新推荐文章于 2024-10-07 19:01:55 发布