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

Input

Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 ... NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, ..., K) are the exponents and coefficients, respectively. It is given that 1 <= K <= 10,0 <= NK < ... < N2 < N1 <=1000.

Output

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<stdio.h>
#include<stdlib.h>
#include<math.h> int main()
{
int n;
int i,j;
double xi;
int zi;
double a[];
int cnt=; for( i=;i<; i++)
{
a[i] = ;
}
for( i=; i<; i++){
scanf("%d",&n);
for( j=; j<n; j++){
scanf("%d %lf",&zi,&xi);
a[zi] += xi;
}
} for( i=; i>=; i--){
if( fabs(a[i])>1e-)
cnt++;
}
printf("%d",cnt);
for( i=; i>=; i--){
if( fabs(a[i])>1e-)
printf(" %d %.1lf",i,a[i]);
} return ;
}

最新文章

  1. Linux查看物理CPU个数、核数、逻辑CPU个数
  2. 【url重写】
  3. UIImagePickerController在ios10环境一打开就crash的问题
  4. Linux安装Redis
  5. 服务器端验证--验证框架验证required.
  6. Git 分支管理是一门艺术
  7. 搭建linux下teamspeak3多人语音服务器
  8. 《JS权威指南学习总结--1.1语言核心》
  9. 利用TinyXml进行数据库的热更新
  10. winserver-查看登陆日志
  11. windows cannot find powershell.exe windows 7
  12. linux上安装mysql5.6
  13. 【翻译】FluentValidation验证组件的使用
  14. XML注释与取消注释快捷键
  15. WebAPi获取请求头中对应键值
  16. TabLayout+ViewPager的简单使用
  17. django 的用户验证及登录状态保持
  18. SQL函数汇总(MySQL教材)
  19. 【Android】7.2 LinearLayout(线性布局)
  20. HDU1160FatMouse&#39;s Speed

热门文章

  1. get和post中文乱码原理相关博客
  2. RMAN-06564错误的原因及解决办法
  3. maven 工程导入jar包
  4. sdut2784&amp;cf 126b Good Luck!(next数组)
  5. Oracle事务控制语言
  6. Neither BindingResult nor plain target object for bean name &#39;user&#39; available as request attribute
  7. php之依赖注入和控制反转
  8. hihocoder1705 座位问题
  9. iOS----时间日期处理
  10. 常用css属性拓展