#include <iostream>
double res[1001]={0};
using namespace std;
int main(int argc, const char * argv[]) {
// insert code here...
int k1,k2;
cin>>k1;
for (int i=0; i<k1; i++) {
int exp;
double cof;
scanf("%d %lf",&exp,&cof);
res[exp]+=cof;
}
cin>>k2;
for (int i=0; i<k2; i++) {
int exp;
double cof;
scanf("%d %lf",&exp,&cof);
res[exp] += cof;
}
int res_k=0;
for (int i=0; i<1001; i++) {
if (res[i]!=0) {
res_k++;
}
}
cout<<res_k;
for (int i=1000; i>=0; i--) {
if (res[i]!=0) {
printf(" %d %.1lf",i,res[i]);
}
}
return 0;
}
PAT甲级 1002 A+B for Polynomials (25)
最新推荐文章于 2022-03-31 12:08:15 发布