PATA1002 A+B for Polynomials

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

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<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int k;
	int m,n,sum=0;
	double t;
	double a[2001]={};
	cin>>m;
	for(int i=0;i<m;i++)
	{
		scanf("%d %lf",&k,&t);
		a[k]+=t;
	}
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d %lf",&k,&t);
		a[k]+=t;
	}
	for(int j=0;j<1999;j++)
	{
		if(a[j]!=0)
		{
			sum++;
		}
	}
	cout << sum;
	for(int j=1999;j>=0;j--)
	{
		if(a[j]!=0)
		{
			printf(" %d %.1f",j,a[j]);
		}
	}
	return 0;
 }

PAT甲级——1002 A+B for Polynomials的更多相关文章

  1. 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 polyno ...

  2. 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 ...

  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 甲级 1002 A+B for Polynomials

    https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000 This time, you are sup ...

  5. pat甲级1002

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

  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——甲级1009:Product of Polynomials;乙级1041:考试座位号;乙级1004:成绩排名

    题目 1009 Product of Polynomials (25 point(s)) This time, you are supposed to find A×B where A and B a ...

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

    题目描述: This time, you are supposed to find A+B where A and B are two polynomials. Input Each input fi ...

  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. Linux简介和环境的搭建

    Linux的学习方向 网络服务器 嵌入式程序开发 Linux的设计哲学:一切皆文件 常用命令:cd 切换目录sudo shutdown -h now 关机命令sudo reboot 重启sudo ro ...

  2. 18 12 23 html 基本学习

    一个html的基本结构如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  3. jvm调优原则

    合理规划jvm性能调优 JVM性能调优涉及到方方面面的取舍,往往是牵一发而动全身,需要全盘考虑各方面的影响.但也有一些基础的理论和原则,理解这些理论并遵循这些原则会让你的性能调优任务将会更加轻松.为了 ...

  4. h5-transform二维变换-扑克牌小案例

    html代码:6张扑克牌 <div class="pkBox"> <img src="../img/pk1.jpg" alt="&q ...

  5. C语言中getopt()和getopt_long()函数的用法

    一.参考文章 1.C语言中getopt()和getopt_long()函数的用法 2.linux 中解析命令行参数 (getopt_long用法) 二.调试经验

  6. django的model字段在保存的时候做预处理怎么办?

    django的model字段在保存的时候做预处理怎么办? 比如这个model: class Book(Model): publish_date = DateField() 但是在保存时,用户输入数据是 ...

  7. Maven--反应堆(Reactor)

    在一个多模块的 Maven 项目中,反应堆是指所有模块组成的一个构建结构.对于单模块的项目,反应堆就是该模块本身.但对于多模块项目来说,反应堆就包含了各模块之间继承与依赖的关系,从而能够自动计算出合理 ...

  8. XCOM串口助手打印不出数据

    本次实验是在基于原子的战舰开发板上的做定时器捕获实验,程序源码下载到板子上运行正常.指示灯正常显示,打开XCOM识别不来串口,原因:硬件上没有插USB转串口线: 连接上USB转串口线,软件上以显示CH ...

  9. h5-提升移动端的响应区域

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 15)png图片旋转贴图

    1)基本代码展示  还是上一个那个总代码: #include<Windows.h> #include<gdiplus.h>//GDI+的头文件 using namespace ...