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 N​1​​ a​N​1​​​​ N​2​​ a​N​2​​​​ ... N​K​​ a​N​K​​​​

where K is the number of nonzero terms in the polynomial, N​i​​ and a​N​i​​​​ (,) 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 分)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 【PAT甲级】1002 A+B for Polynomials (25 分)

    题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数. AAAAAccepted code: #include<bits/stdc++.h> usin ...

  6. 1002 A+B for Polynomials (25分) 格式错误

    算法笔记上能踩的坑都踩了. #include<iostream> using namespace std; float a[1001];//至少1000个位置 int main(){ in ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. <NET CLR via c# 第4版>笔记 第11章 事件

    11.1 设计要公开事件的类型 11.1.1 第一步: 定义类型来容纳所有需要发送给事件通知接收者的附加信息 //第一步:定义一个类型来容纳所有应该发送给事件通知接收者的附加信息 internal c ...

  2. define 常量的定义和读取

    define(‘常量’,‘常量值’)----------------------define来定义常量, echo 也能输出常量, get_defined_constants(true)------- ...

  3. php 从2维数组组合为四维数组分析

  4. PHP文件上传大小设置

    PHP.INI配置:文件上传功能配置教程 打开php.ini配置文件中的upload_tmp_dir.upload_max_filesize.post_max_size等选项. php.ini中文件上 ...

  5. iOS8 对开发者来说意味着什么?

    今天凌晨,Apple WWDC2014 iOS8 正式推出! 也许,对于广大iOS用户来说,iOS8的创新并不是特别多. 但对于开发者来说,影响却将会是无比巨大的! 正如Apple官网上的广告:Hug ...

  6. 设计Popup Window

    设计一个Popup window, 在其中实现分享到Facebook 和Twitter 功能. popup window 名称为 ShareView.xaml, 代码如下: <phone:Pho ...

  7. 前端开发 —— js 常用工具函数(utilities)

    1. 时间 function getCurTime() { var date = new Date(); return date.toLocaleTimeString(); } date.toLoca ...

  8. STM32中断定时,控制LED灯

    #include "led.h" void TIM3_Int_Init(u16 arr,u16 psc) { TIM_TimeBaseInitTypeDef TIM_TimeBas ...

  9. 51Nod:1003 阶乘后面0的数量

    1003 阶乘后面0的数量  基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 72 ...

  10. 前端jquery---表单验证

    重点: 1.表单的提交 2.触发blur事件 3.判断是否正确,提交与否 return False <!DOCTYPE html> <html lang="en" ...