1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 struct node 5 { 6 int n; 7 double a;//n为次数,a为系数 8 }; 9 int main() 10 { 11 vector<node> v1,v2; 12 int k; 13 cin >> k; 14 struct node* p =new struct node; 15 while(k--) 16 { 17 cin >> p->n >> p->a; 18 v1.push_back(*p); 19 } 20 vector<node>::iterator it1; 21 vector<double> v3(2002); 22 cin >> k; 23 while(k--) 24 { 25 cin >> p->n >> p->a; 26 for(it1 = v1.begin(); it1 != v1.end(); ++it1) 27 v3[p->n + it1->n] += p->a * it1->a; 28 } 29 int cnt = 0; 30 for(int i = 0; i<=2001; ++i) 31 { 32 if(v3[i] != 0) 33 ++cnt; 34 } 35 printf("%d",cnt); 36 for(int i = 2001; i >= 0; --i) 37 { 38 if(v3[i] != 0) 39 printf(" %d %.1f",i,v3[i]); 40 } 41 return 0; 42 }