This time, you are supposed to find A+B where A and B are two polynomials.

Input Specification:

Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:

K N​1​​ a​N​1​​​​ N​2​​ a​N​2​​​​ ... N​K​​ a​N​K​​​​

where K is the number of nonzero terms in the polynomial, N​i​​ and a​N​i​​​​ (,) are the exponents and coefficients, respectively. It is given that 1,0.

Output Specification:

For each test case you should output the sum of A and B in one line, with the same format as the input. Notice that there must be NO extra space at the end of each line. Please be accurate to 1 decimal place.

Sample Input:

2 1 2.4 0 3.2
2 2 1.5 1 0.5

Sample Output:

3 2 1.5 1 2.9 0 3.2
#include<iostream>
using namespace std;
int main(){
int m,n,i,temp,count=0;
float a[1002],b[1002];
cin>>m;
for(i=0;i<m;i++){
cin>>temp;
cin>>a[temp];
}
cin>>n;
for(i=0;i<n;i++){
cin>>temp;
cin>>b[temp];
if(a[temp]==0){
a[temp]=b[temp];
}
else{
a[temp]+=b[temp];
}
}
for(i=0;i<1001;i++){
if(a[i]!=0)
count++;
}
cout<<count;
for(i=1000;i>=0;i--){
if(a[i]!=0){
printf(" %d %.1f",i,a[i]);
}
}
return 0;
}

  

最新文章

  1. Unity依赖注入使用
  2. centOS安装nginx
  3. 2015年第3本(英文第2本):Daughter of Deceit
  4. 如何将NTFS格式的移动硬盘挂接到Mac OS上进行读写(Read/Write)操作
  5. codefoces round193a
  6. RHEL安装docker-compose
  7. Matlab中imshow()函数的使用
  8. Unity3d 协程、调用函数、委托
  9. ruby编程语言-学习笔记3(第4章 表达式和操作符)
  10. 减少 WAF 漏报的 8 种方法 !
  11. [置顶] Guava学习之Lists
  12. 在Android手机上获取其它应用的包名及版本
  13. android开发进阶学习博客资源
  14. 如何使用LIBSVM,从安装到基本实例使用
  15. ssh框架-Struts2(二)
  16. QT中对内存的管理
  17. django websocket
  18. 关于 atcoder 页面美化的 css
  19. ES5之函数的间接调用 ( call、apply )、绑定 ( bind )
  20. IOS绘图详解

热门文章

  1. Spring源码窥探之:扩展原理BeanDefinitionRegistryPostProcessor
  2. Java代码写PDF-保全批单
  3. 15-Flutter移动电商实战-商品推荐区域制作
  4. learning armbian steps(11) ----- armbian 源码分析(六)
  5. C# list常用的几个操作 改变list中某个元素的值 替换某一段数据
  6. select count(1)和 select count(*)
  7. Noip2019暑期训练2 反思
  8. leetcode 删除一张表中重复邮箱的数据,并且保留最小id 的 那条
  9. Win7下安装VS2017、安装Qt5.10.1以及在VS2017添加qt插件
  10. deepin深度学习环境配置