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

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. 杭电oj初体验之 Code

    PLA算法: https://blog.csdn.net/red_stone1/article/details/70866527 The problem: Analysis: 题目链接可见:https ...

  2. 洛谷 P1659 [国家集训队]拉拉队排练(Manacher)

    题目链接:https://www.luogu.com.cn/problem/P1659 思路: 首先跑一遍Manacher,用$cnt_i$记录长为$i$的回文串有多少个. 所记录的$cnt$并不是最 ...

  3. Oracle使用记录

    1.连接数据库的方式 sqlplus system/system@127.0.0.1:1521/orcl #远程用户名密码连接 sqlplus dbsnmp/oracle; #本地用户名密码连接 sq ...

  4. dbGet (二)

    dbGet是由它基本的语法加上各种object的attribute的组合构成的.大家在熟悉基本语法之后,就应该去学习各个object的attribute了.说实话,这很难,因为attribute很多, ...

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

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

  6. split()函数+merge()函数

    在图像处理时,我们接触到的彩色以RGB居多,为了分析图像在某一通道上的特性,需要将图像的颜色通道进行分离,或者是在对某一颜色通道处理后重新进行融合.opencv提供了split()函数来进行颜色通道的 ...

  7. C# byte[]转string, string转byte[] 的四种方法

    转载:https://blog.csdn.net/tom_221x/article/details/71643015 第一种 string  str    = System.Text.Encoding ...

  8. SQL Server 函数大全

    本文链接:https://blog.csdn.net/qq_15028299/article/details/81330854SQL2008 表达式:是常量.变量.列或函数等与运算符的任意组合.htt ...

  9. GEE引擎假人系统自定义教程

    现如今传奇游戏玩家数量日渐减少.为了给服务器增加人气,很多GM在服务端中增加了自动登录和自动打怪的假人系统.由于该系统登录的假人可以自动练功,自动攻城和实现简单的对话.完全可以做到以假乱真的地步!所以 ...

  10. CRT中国剩余定理 & Lucas卢卡斯定理

    数论_CRT(中国剩余定理)& Lucas (卢卡斯定理) 前言 又是一脸懵逼的一天. 正文 按照道理来说,我们应该先做一个介绍. 中国剩余定理 中国剩余定理,Chinese Remainde ...