为0的不要输出。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;double a[1500],b[1500];
int k;int main()
{for(int i=0;i<=1000;i++) a[i]=b[i]=0;int Max=-1;scanf("%d",&k);for(int i=1;i<=k;i++){int id;double num;scanf("%d%lf",&id,&num);Max=max(Max,id);a[id]=num;}scanf("%d",&k);for(int i=1;i<=k;i++){int id;double num;scanf("%d%lf",&id,&num);Max=max(Max,id);b[id]=num;}int cnt=0;for(int i=Max;i>=0;i--)if(a[i]+b[i]!=0) cnt++;printf("%d",cnt);int op=0;for(int i=Max;i>=0;i--){if(a[i]+b[i]!=0){printf(" %d %.1lf",i,a[i]+b[i]);}}return 0;
}

转载于:https://www.cnblogs.com/zufezzt/p/5495933.html

PAT (Advanced Level) 1002. A+B for Polynomials (25)相关推荐

  1. 【PAT (Advanced Level) Practice】1051 Pop Sequence (25 分)

    1051 Pop Sequence (25 分) Given a stack which can keep M numbers at most. Push N numbers in the order ...

  2. 【PAT (Advanced Level) Practice】1037 Magic Coupon (25 分)

    题意: 给出两个集合,从这两个集合里面选出数量相同的元素进行一对一相乘,求能够得到的最大乘积之和. 题解: 对每个集合,将正数和负数分开考虑,将每个集合里的整数从大到小排序:将每个集合里的负数从小到大 ...

  3. PAT (Advanced Level) Practise 1013. Battle Over Cities (25)

    1013. Battle Over Cities (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...

  4. PAT (Advanced Level) Practice 题目集合(1001 ~ 1050)(正在更新)

    1001 A+B Format (20 分) 题目大意:计算a+b,结果按照西方的那种写数字的方式输出,从三个数一个逗号那种. #include<bits/stdc++.h> using ...

  5. PAT (Advanced Level) Practice 1043 Is It a Binary Search Tree (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1043 Is It a Binary Search Tree (25 分) 凌宸1642 题目描述: A Binary Search Tr ...

  6. PAT (Advanced Level) Practice 题解代码 - II (1051-1100)

    PAT PAT (Advanced Level) Practice - II(1051-1100) -------------------------------------------------- ...

  7. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  8. 【PAT (Advanced Level) Practice】1002 A+B for Polynomials (25 分)

    #include<iostream> #include<string> #include<cstring> #include<cstdio> #incl ...

  9. PAT (Advanced Level) Practise 1004 解题报告

    GitHub markdownPDF 问题描述 解题思路 代码 提交记录 问题描述 Counting Leaves (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 1600 ...

最新文章

  1. JavaScript 工作原理(二)-如何在 V8 引擎中书写最优代码的 5 条小技巧(译)
  2. WPF 分页控件的简单实现
  3. 覆盖所有面试知识点,建议收藏
  4. 微信小程序入门五: wxml文件引用、模版、生命周期
  5. 机器人 铑元素_智能机器人 三十三
  6. 混合编程:如何用pybind11调用C++
  7. python输出欢迎某某某_Python基础中所出现的异常报错总结,python基础总结
  8. 数值优化(Numerical Optimization)学习系列-序列二次规划和内点法(SQP、Interior-Point)
  9. 前端 如何检测到当前的网页已经退出_如何监控网页崩溃?
  10. git、KDiff3、Git Extensions
  11. 什么是Xcelsius
  12. 徒步运动软件怎么申请测试,徒步,不仅是体质健康的锻炼和检测,还是心理健康成长的过程...
  13. Botler.ai为美国和加拿大推出性骚扰检测机器人
  14. ### Cause: java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字
  15. QFileInfo截取文件后缀
  16. QT运行时问题CreateDC failed
  17. html怎么转换成ftl模板,FreeMarker入门+模板静态化+模板字符串静态化
  18. springDataJpa @Query注解多条件动态模糊分页查询,传入形参对象
  19. Git帝国之tag大臣
  20. 手机QQ2008下载地址

热门文章

  1. Matlab subs函数的用法
  2. HDU 6264 Super-palindrome
  3. 金九银十,史上最强 Java 面试题整理。
  4. MyBatis学习与使用(一)
  5. Observer(订阅与发布)
  6. iOS微博项目(一)
  7. Java提高学习之Object(3)
  8. 解决 FTPClient 出现的553错误
  9. .net身份证号码验证
  10. XML中预定义好的实体