1002 A+B for Polynomials (25 分)
This time, you are supposed to find A+B where A and B are two polynomials.
Input Specification:
Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:
K N1 aN1 N2 aN2 ... NK aNK
where K is the number of nonzero terms in the polynomial, Ni and aNi (,) are the exponents and coefficients, respectively. It is given that 1,0.
Output Specification:
For each test case you should output the sum of A and B in one line, with the same format as the input. Notice that there must be NO extra space at the end of each line. Please be accurate to 1 decimal place.
Sample Input:
2 1 2.4 0 3.2
2 2 1.5 1 0.5
Sample Output:
3 2 1.5 1 2.9 0 3.2
分析: 多项式加法,水题~
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-23-20.32.18
* Description : A1002
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
;
};
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
;
double a;
scanf("%d",&k);
;i<k;i++){
scanf("%d%lf",&n,&a);
p[n]+=a;
}
scanf("%d",&k);
;i<k;i++){
scanf("%d%lf",&n,&a);
p[n]+=a;
}
;i<maxn;i++){
){
num++;
}
}
printf("%d",num);
;i>=;i--){
){
printf(" %d %.1f",i,p[i]);
}
}
;
}
1002 A+B for Polynomials (25 分)的更多相关文章
- 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 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 1002 A+B for Polynomials (25分)
题目 This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: E ...
- 1002 A+B for Polynomials (25分)
This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each ...
- 【PAT甲级】1002 A+B for Polynomials (25 分)
题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数. AAAAAccepted code: #include<bits/stdc++.h> usin ...
- 1002 A+B for Polynomials (25分) 格式错误
算法笔记上能踩的坑都踩了. #include<iostream> using namespace std; float a[1001];//至少1000个位置 int main(){ in ...
- P1002 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 polyn ...
- PAT 1009 Product of Polynomials (25分) 指数做数组下标,系数做值
题目 This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: E ...
- 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 ...
- 1002 A+B for Polynomials (25)(25 point(s))
problem 1002 A+B for Polynomials (25)(25 point(s)) This time, you are supposed to find A+B where A a ...
随机推荐
- Python 数值计算库之-[Pandas](六)
- html <meta>设置自动刷新或者几秒内跳转到指定页面
指定时间自动刷新: <meta http-equiv="refresh" content="2"/> 指定时间跳转到指定页面: <meta h ...
- web.xml的分析
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" ...
- anu - browser
import { oneObject, recyclables, typeNumber } from "./util"; //用于后端的元素节点 export function D ...
- 保护 iOS 用户数据安全: Keychain 和 Touch ID
原文:How To Secure iOS User Data: The Keychain and Touch ID 作者:Tim Mitra 译者:kmyhy 更新说明:本教程由 Tim Mitra ...
- Unity 3D游戏-塔防类游戏源码:重要方法和功能的实现
Unity-塔防游戏源码 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) 1 2 3 4 5 6 7 8 9 ...
- SharePoint PeopleEditor控件使用
以下用于简要介绍在SharePoint 2016二次开发中如何使用PeopleEditor人员选择器,并采用前端的方式获取和设置值. 一.在使用的.aspx页面进行注册 <%@ Register ...
- redis sentinel 高可用(HA)方案部署,及python应用示例
redis sentinel(哨兵)高可用集群的部署方法,并通过 python 程序实例讲解如何使用 redis sentinel 简介 介绍 redis sentinel(哨兵)集群的部署,配置一主 ...
- WPF 带CheckBox、图标的TreeView(转)
在WPF实际项目开发的时候,经常会用到带CheckBox的TreeView,虽然微软在WPF的TreeView中没有提供该功能,但是微软在WPF中提供强大的ItemTemplate模板功能和自定义样式 ...
- JSONObject JSONArray json字符串 HashMap ArryList 在java开发中用到的数据结构
1.JSONObject 长成这样的: { "key1":value1, "key2":value2, "key3":value3} ...