PAT (Advanced Level) 1002. A+B for Polynomials (25)
为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)相关推荐
- 【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 ...
- 【PAT (Advanced Level) Practice】1037 Magic Coupon (25 分)
题意: 给出两个集合,从这两个集合里面选出数量相同的元素进行一对一相乘,求能够得到的最大乘积之和. 题解: 对每个集合,将正数和负数分开考虑,将每个集合里的整数从大到小排序:将每个集合里的负数从小到大 ...
- PAT (Advanced Level) Practise 1013. Battle Over Cities (25)
1013. Battle Over Cities (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- PAT (Advanced Level) Practice 题目集合(1001 ~ 1050)(正在更新)
1001 A+B Format (20 分) 题目大意:计算a+b,结果按照西方的那种写数字的方式输出,从三个数一个逗号那种. #include<bits/stdc++.h> using ...
- 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 ...
- PAT (Advanced Level) Practice 题解代码 - II (1051-1100)
PAT PAT (Advanced Level) Practice - II(1051-1100) -------------------------------------------------- ...
- 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 ...
- 【PAT (Advanced Level) Practice】1002 A+B for Polynomials (25 分)
#include<iostream> #include<string> #include<cstring> #include<cstdio> #incl ...
- PAT (Advanced Level) Practise 1004 解题报告
GitHub markdownPDF 问题描述 解题思路 代码 提交记录 问题描述 Counting Leaves (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 1600 ...
最新文章
- JavaScript 工作原理(二)-如何在 V8 引擎中书写最优代码的 5 条小技巧(译)
- WPF 分页控件的简单实现
- 覆盖所有面试知识点,建议收藏
- 微信小程序入门五: wxml文件引用、模版、生命周期
- 机器人 铑元素_智能机器人 三十三
- 混合编程:如何用pybind11调用C++
- python输出欢迎某某某_Python基础中所出现的异常报错总结,python基础总结
- 数值优化(Numerical Optimization)学习系列-序列二次规划和内点法(SQP、Interior-Point)
- 前端 如何检测到当前的网页已经退出_如何监控网页崩溃?
- git、KDiff3、Git Extensions
- 什么是Xcelsius
- 徒步运动软件怎么申请测试,徒步,不仅是体质健康的锻炼和检测,还是心理健康成长的过程...
- Botler.ai为美国和加拿大推出性骚扰检测机器人
- ### Cause: java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字
- QFileInfo截取文件后缀
- QT运行时问题CreateDC failed
- html怎么转换成ftl模板,FreeMarker入门+模板静态化+模板字符串静态化
- springDataJpa @Query注解多条件动态模糊分页查询,传入形参对象
- Git帝国之tag大臣
- 手机QQ2008下载地址