【PAT甲级】1002 A+B for Polynomials (25 分)
题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数。
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 分)的更多相关文章
- 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 ...
- PAT 甲级1002 A+B for Polynomials (25)
1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...
- 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 ...
- 【PAT甲级】1009 Product of Polynomials (25 分)
题意: 给出两个多项式,计算两个多项式的积,并以指数从大到小输出多项式的指数个数,指数和系数. trick: 这道题数据未知,导致测试的时候发现不了问题所在. 用set统计非零项时,通过set.siz ...
- 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 ...
- PAT甲级:1036 Boys vs Girls (25分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- PAT甲级:1089 Insert or Merge (25分)
PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...
- 【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 ...
- 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 ...
- PAT 甲级 1145 Hashing - Average Search Time (25 分)(读不懂题,也没听说过平方探测法解决哈希冲突。。。感觉题目也有点问题)
1145 Hashing - Average Search Time (25 分) The task of this problem is simple: insert a sequence of ...
随机推荐
- 【做题笔记】洛谷P1036 选数
作为一个 DFS 初学者这题真的做得很惨...其实窝学 DFS 一年多了,然后一开始就学不会最近被图论和数据结构打自闭后才准备好好学一学233 一开始,直接套框架,于是就有 #include < ...
- docker容器 - 导入容器、导出容器、查看容器
实验环境 CentOS 7.5 容器 容器是镜像的运行实例.不同的是,镜像是静态的只读文件,而容器带有运行时需要的可写文件层:同时,容器中的应用进程处于运行状态. 导入和导出容器 实现容器的迁移. 导 ...
- appium---切换webview时报错
在上一篇中简单介绍了如何查看webview和切换到webview的方法,可能第一次切换webview的时候会报错“Error: session not created exception: Chrom ...
- 空字符串(“”)和null和空格字符串(" ")的区别
1.类型 null表示的是一个对象的值,而并不是一个字符串.例如声明一个对象的引用,String a = null ;""表示的是一个空字符串,也就是说它的长度为0,但它是一个字符 ...
- 对于一些stl自定义比较函数
1.unorderd_map自定义键 自定义类型 struct my_key { int num; string name; }; 1.由于unordered_map是采用哈希实现的,对于系统的类型i ...
- C# 将DataGridView中显示的数据导出到Excel(.xls和.xlsx格式)—NPOI
前言 https://blog.csdn.net/IT_xiao_guang_guang/article/details/104217491 本地数据库表中有46785条数据,测试正常 初次运行程 ...
- sklearn 线性回归
# import numpy as np import pandas as pd from pandas import Series,DataFrame import matplotlib.pyplo ...
- oracle备份报“EXP-00056: 遇到 ORACLE 错误 12541”
今天准备接手一个新项目,首先是dang项目和备份数据库到本地,但是在备份数据库的时候报错误: EXP-00056: 遇到 ORACLE 错误 12541 ORA-12541: TNS: 无监听程序 E ...
- Django Web接口开发
什么是接口 接口一般来讲分为两种: (1)程序内部的接口:方法与方法.模块与模块之间的交互,程序内部抛出的接口,如登录发帖,发帖就必须要登录,如果不登录不能发帖,发帖和登录这两个模块之间就要有交互,就 ...
- python学习之matplotlib绘制动图(FuncAnimation()参数)
1.函数FuncAnimation(fig,func,frames,init_func,interval,blit)是绘制动图的主要函数,其参数如下: a.fig 绘制动图的画布名称 b.func自定 ...