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 ;
}

1002. A+B for Polynomials (25) (浮点数判0)的更多相关文章

  1. PAT 1002. A+B for Polynomials (25) 简单模拟

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  2. PAT甲 1002. A+B for Polynomials (25) 2016-09-09 22:50 64人阅读 评论(0) 收藏

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  3. PAT 甲级1002 A+B for Polynomials (25)

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  4. PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642 题目描述: This time, you are suppos ...

  5. 1002 A+B for Polynomials (25)(25 point(s))

    problem 1002 A+B for Polynomials (25)(25 point(s)) This time, you are supposed to find A+B where A a ...

  6. 【PAT】1002. A+B for Polynomials (25)

    1002. A+B for Polynomials (25) This time, you are supposed to find A+B where A and B are two polynom ...

  7. PAT甲级 1002 A+B for Polynomials (25)(25 分)

    1002 A+B for Polynomials (25)(25 分) This time, you are supposed to find A+B where A and B are two po ...

  8. 1002. A+B for Polynomials (25)

    题目链接:https://www.patest.cn/contests/pat-a-practise/1002 原题如下: This time, you are supposed to find A+ ...

  9. PAT Advanced 1002 A+B for Polynomials (25 分)(隐藏条件,多项式的系数不能为0)

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

随机推荐

  1. 暴力 Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II

    题目传送门 /* 暴力:O (n^2) */ #include <cstdio> #include <algorithm> #include <cstring> # ...

  2. 题解报告:hdu 1062 Text Reverse

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 Problem Description Ignatius likes to write word ...

  3. 加密解密(4)SSL协议及HTTPS握手过程

    SSL协议 简介 SSL (Secure Sockets Layer 安全套接层)是一个安全协议,它提供使用 TCP/IP 的通信应用程序间的隐私与完整性.因特网的 超文本传输协议 (HTTP)使用 ...

  4. import android.support.v4或者import android.support.v7提示导入错误解决办法

    转自:  http://blog.csdn.net/forandever/article/details/37655139 在使用Eclipse开发andriod程序时,程序中提示import and ...

  5. C# KeepAlive的设置

    C# KeepAlive的相关设置 网上有很多相关KeepAlive的内容,终于找到了有关C#的这方面资料,设置了下,有行可靠! TcpListener myListener = new TcpLis ...

  6. 自学 iOS - 三十天三十个 Swift 项目 第三天

    做了这个小demo 之后  感觉OC 和swift 还是有很大的差别的 自己还是要去多看些swift的语法 用的不是很熟练 1.这个demo 的资源文件 我都是用原工程的 2.同样的自定义cell 的 ...

  7. 看到了一篇不错的tensorflow文章

    http://dataunion.org/28906.html 本文作者 Steven Dufresne,总结了新手学 TensorFlow 需要的核心知识点和实操内容,旨在鼓励更多人借 Tensor ...

  8. 【4412开发板使用经验分享】迅为4412开发板I2C驱动问题

    本文转自迅为论坛:bbs.topeetboard.com 我想写DS3231 的驱动 但是读回的数据老是-6 硬件: 我I2C设备连接的这几个GPIO,看了2.5的手册,接口应该是链接正确的 软件 分 ...

  9. PC端浏览器定位

    第一: PC端浏览器定位(纯前端)浏览器定位 :这里用了两种 ,一种是Html5自带的方法 另一种是引用了百度api  ,百度api 的使用有三种:1 浏览器定位2 ip定位3 SDK辅助定位引用百度 ...

  10. zTree 点击文字 勾选check

    callback: { onClick:function(event, treeId, treeNode){ console.info("onClick") var treeObj ...