题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数。

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
double a[];
int main(){
int k;
cin>>k;
int max_n=;
for(int i=;i<=k;++i){
int n;
cin>>n;
double x;
cin>>x;
a[n]+=x;
max_n=max(max_n,n);
}
cin>>k;
for(int i=;i<=k;++i){
int n;
cin>>n;
double x;
cin>>x;
a[n]+=x;
max_n=max(max_n,n);
}
int cnt=;
for(int i=;i<=max_n;++i)
if(a[i])
cnt++;
cout<<cnt;
for(int i=max_n;i>=;--i)
if(a[i])
printf(" %d %.1f",i,a[i]);
return ;
}

【PAT甲级】1002 A+B for Polynomials (25 分)的更多相关文章

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

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

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

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

  4. 【PAT甲级】1009 Product of Polynomials (25 分)

    题意: 给出两个多项式,计算两个多项式的积,并以指数从大到小输出多项式的指数个数,指数和系数. trick: 这道题数据未知,导致测试的时候发现不了问题所在. 用set统计非零项时,通过set.siz ...

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

  6. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  7. PAT甲级:1089 Insert or Merge (25分)

    PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...

  8. 【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 ...

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

  10. PAT 甲级 1145 Hashing - Average Search Time (25 分)(读不懂题,也没听说过平方探测法解决哈希冲突。。。感觉题目也有点问题)

    1145 Hashing - Average Search Time (25 分)   The task of this problem is simple: insert a sequence of ...

随机推荐

  1. tomcat、nginx、apache、tengine都是什么,及其作用

      Tomcat的功能职责:Tomcat运行在JVM之上,它和HTTP服务器一样,绑定IP地址并监听TCP端口,同时还包含以下指责: • 管理Servlet程序的生命周期• 将URL映射到指定的Ser ...

  2. xhr 的 onpregress 监听上传数据的 已上传 和 总大小

    var fd=new FormData(); $('.mwd_uppingzheng_btna_ok').on('click',function () { // 数组转 str var strarr= ...

  3. 安装mongo以及相关扩展

    背景:看到了一个nodejs的对mongo操作的课程,于是想学一下. * 1.于是打算先在自己的vps上安装一个mongodb:[ https://docs.mongodb.org/manual/tu ...

  4. springmvc validator和springContext validator的区别

    1.springContext validator 依赖于代理实现 MethodValidationInterceptor Set<ConstraintViolation<Object&g ...

  5. qxdm,qpst,qcat抓包分析VoLTE SIP协商包

    QXDM,QPST和QCAT是Qualcomm高通公司针对高通芯片的抓包分析工具. QXDM抓包分析,QPST与手机com口连接,QCAT用来分析抓包产生的isf文件(log). 使用版本: QXDM ...

  6. C语言字符串类型转换为double浮点数类型

    #include <stdio.h>#include <stdlib.h>char *record; double re = atof(record); 使用 atof()函数 ...

  7. JDBC--处理Blob

    1.LOB(Large Objects)大对象,是用来存储大量的二进制和文本数据的一种数据类型(一个LOB字段可存储多达4GB的数据) --LOB分类两种类型:1)内部LOB: 2)外部LOB: -- ...

  8. 安装docker并使用docker安装mysql

    安装Docker 1. Docker 教程地址:https://www.runoob.com/docker/centos-docker.install.html 2.安装docker 命令:yum i ...

  9. js克隆一个对象

    我们知道,对象类型在赋值的过程中其实是复制了地址,所以如果改变了一方,其他都会被改变.我们应该如何克隆一个对象,并且避免这种现象的发生呢? 方法一:Object.assign function cop ...

  10. 3、示例(在java中使用JSON)

    教程链接(json-smple1.1.1.jar文件) 链接:http://pan.baidu.com/s/1qXPbYHm 密码:v0f0 如何使用java编程语言编码和解码JSON 首先准备环境以 ...