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. Arduino LiquidCrystal库函数中文对照

    我之所以会试试看LCD+Shield,一是因为我本来就有这块板,但一直不会用,第二个原因则是Arduino+Cookbook这本书.O’Reilly的这本手册对你在Arduino实践中的各种问题(几乎 ...

  2. zabbix安装及配置

    一.安装zabbix_server 二.安装zabbix_agent 三.zabbix配置详解

  3. python一个正则表达式的不解

    htmlSource="data-lazy=\"http://gtms01.alicdn.com/tps/i1/T1faOCFQXXXXc2jIrl-.png\"&quo ...

  4. CF #610Div2 B2.K for the Price of One (Hard Version) (dp解法 && 贪心解法)

    原题链接:http://codeforces.com/contest/1282/problem/B2题目大意:刚开始有 p 块钱,商店有 n 件物品,你每次可以只买一件付那一件的钱,也可以买 k 件只 ...

  5. stegsolve使用方法

    Stegsolve使用方法(是因为ctf题总是遇到并且目前百度没有十分详细的探究说明) 这个没什么好说的,打开文件 ,保存,退出 在分析里面从上到下的依次意思是 File Format:文件格式 Da ...

  6. ES6 之 对象的扩展

    1.Object.is() 判断俩个值是否相等 +0 不等于 -0 NaN 等于自身 console.log(Object.is('foo','foo')); // true console.log( ...

  7. JDK安装 - Linux环境

    JDK安装 - Linux环境 1. 下载 :https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-21331 ...

  8. 实验吧web-易-这个看起来有点简单

    看url中有id=1,明显的sql注入,这里使用手工注入不适用sqlmap,想用的话参考文章(传送门) 1.首先测试有没有sql注入漏洞, http://ctf5.shiyanbar.com/8/in ...

  9. CentOS系统安装过程中配置软RAID-0或RAID-1

    什么是RAID-0 RAID-0 (等量模式, stripe):效能最佳.这种模式如果使用相同型号与容量的磁碟来组成时,效果较佳.这种模式的 RAID 会将磁碟先切出等量的区块 (举例来说, 4KB) ...

  10. 第22章 Makefile基础

    一.自动处理头文件的依赖关系 在Makefile中插入如下代码: include $(sources:.c=.d) %.d: %.c set -e; rm -f $@; \ $(CC) -MM $(C ...