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

  

A+B for Polynomials的更多相关文章

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

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

  2. PAT (Advanced Level) Practise:1002. A+B for Polynomials

    [题目链接] This time, you are supposed to find A+B where A and B are two polynomials. Input Each input f ...

  3. \(\S1 \) Gaussian Measure and Hermite Polynomials

    Define on \(\mathbb{R}^d\) the normalized Gaussian measure\[ d \gamma(x)=\frac{1}{(2\pi)^{\frac{d}{2 ...

  4. 1002. A+B for Polynomials

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

  5. Legendre polynomials

    In mathematics, Legendre functions are solutions to Legendre's differential equation: In particular, ...

  6. PAT 解题报告 1009. Product of Polynomials (25)

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

  7. 【PAT】1009. Product of Polynomials (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...

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

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

  9. PAT1009:Product of Polynomials

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  10. PAT1002:A+B for Polynomials

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

随机推荐

  1. Ubuntu 14.04.2配置rsync

    ubuntu系统自带rsync,首先配置/etc/default/rsync,启用daemon模式 修改/etc/rsyncd.conf配置文件 cat /etc/rsyncd.conf # samp ...

  2. linux下使用rzsz实现文件的上传和下载

    新搞的云服务器用SecureCRT不支持上传和下载,没有找到rz命令.记录一下如何安装rz/sz命令的方法. 一.工具说明 在SecureCRT这样的ssh登录软件里, 通过在Linux界面里输入rz ...

  3. 题解 UVa11609

    题目大意 给定一个正整数 \(n\),请求出所有小于 \(n\) 人的团队如果选出一个人作为队长的不同的方案数(假定这些人两两不相同)对 \(10^9+7\)取模的结果. 分析 即求 \[\sum^n ...

  4. P2915 [USACO08NOV] Mixed Up Cows

    题目描述 Each of Farmer John's N (4 <= N <= 16) cows has a unique serial number S_i (1 <= S_i & ...

  5. 含-SH的ACE抑制药的青霉胺样反应

    关于 含-SH的血管紧张素转化酶(ACE)抑制药如卡托普利具有青霉胺样反应.而依那普利则不含-SH. 青霉胺样反应 青霉胺样反应,指应用含-SH的ACE抑制药产生的皮疹.嗜酸性粒细胞(E)增多.味觉异 ...

  6. 基于C+OpenCV4.0的LineSegmentDetector算法实现

    简单记录LSD算法的实现过程,当做备忘录用,如有问题欢迎指出和讨论 LSD的基本实现流程是计算出图像的梯度和场方向,然后对梯度进行排序,然后从大到小进行区域增长,之后对增长得到的区域求最小外接矩形,如 ...

  7. 数据库服务器和web服务器磁盘占用查询

    对于Oracle数据库而言磁盘空间主要体现在表空间上,可使用sql语句进行查看Oracle 表空间的大小及使用情况: select sum(bytes)/1024/1024/1024 "Gb ...

  8. vue 项目的文件/文件夹上传下载

    前言:因自己负责的项目(jetty内嵌启动的SpringMvc)中需要实现文件上传,而自己对java文件上传这一块未接触过,且对 Http 协议较模糊,故这次采用渐进的方式来学习文件上传的原理与实践. ...

  9. WinDbg常用命令系列---显示加载的模块列表lm

    lm (List Loaded Modules) lm命令显示指定的加载模块.输出包括模块的状态和路径. lmOptions [a Address] [m Pattern | M Pattern] 参 ...

  10. Linux 重启 PHP-FPM 命令

    1. 停止命令 pkill php-fpm 2.重启或启动命令 php-fpm -R