#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
// insert code here...
int k;
double a[1001];
fill(a, a + 1001, 0);
scanf("%d", &k);
int e;
double c;
for (int i = 0; i < k; i++) {
scanf("%d %lf", &e, &c );
a[e] = c;
}
scanf("%d", &k);
int cnt = 0;
for (int i = 0; i < k; i++) {
scanf("%d %lf", &e, &c );
a[e] += c;
}
for (int i = 0; i < 1001; i++) {
if (a[i]) {//即使是浮点数在没有要求精度范围时 这样做也是最正确的
cnt++;
}
}
printf("%d", cnt);
for (int i = 1000; i >= 0; i--) {
if (a[i]) {
printf(" %d %.1lf", i, a[i]);
}
}
printf("\n");
return 0;
}
相关文章
- 05-16PTA 甲级 1009 Product of Polynomials (25 分) 多项式相乘
- 05-16A1002. A+B for Polynomials
- 05-16入门模拟A1009 Product of Polynomials(25)
- 05-16[PAT] A1002 A+B for Polynomials (23分!)
- 05-161009 Product of Polynomials (25 分)
- 05-161009 Product of Polynomials (25分)
- 05-161002 A+B for Polynomials 可弃
- 05-161009 Product of Polynomials (25 分)
- 05-16PAT A1009 Product of Polynomials (25分)
- 05-16PAT甲 1001. A+B Format (20) 2016-09-09 22:47 25人阅读 评论(0) 收藏