1009 Product of 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 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​​​​ (i=1,2,⋯,K) are the exponents and coefficients, respectively. It is given that 1≤K≤10, 0≤N​K​​<⋯<N​2​​<N​1​​≤1000.

Output Specification:

For each test case you should output the product 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 up to 1 decimal place.

Sample Input:

2 1 2.4 0 3.2
2 2 1.5 1 0.5

Sample Output:

3 3 3.6 2 6.0 1 1.6

分析:多项式乘法, 要注意数组要开到2000以上。
 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-23-20.49.16
 * Description : A1009
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 using namespace std;
 ;
 },ans[maxn]={};
 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);
         ;j<maxn;j++){
             ){
                 ans[j+n]+=p[j]*a;
             }
         }
     }
     ;i<maxn;i++){
         ){
             num++;
         }
     }
     printf("%d",num);
     ;i>=;i--){
         ){
             printf(" %d %.1f",i,ans[i]);
         }
     }
     ;
 }
 

1009 Product of Polynomials (25 分)的更多相关文章

  1. 1009 Product of Polynomials (25分) 多项式乘法

    1009 Product of Polynomials (25分)   This time, you are supposed to find A×B where A and B are two po ...

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

  3. PAT Advanced 1009 Product of Polynomials (25 分)(vector删除元素用的是erase)

    This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...

  4. 【PAT甲级】1009 Product of Polynomials (25 分)

    题意: 给出两个多项式,计算两个多项式的积,并以指数从大到小输出多项式的指数个数,指数和系数. trick: 这道题数据未知,导致测试的时候发现不了问题所在. 用set统计非零项时,通过set.siz ...

  5. 1009 Product of Polynomials (25分) 晚上脑子就是容易僵住

    #include<iostream> using namespace std; struct { int a; double b; }poly[1001]; double a[2001]; ...

  6. PAT 甲级 1009 Product of Polynomials (25)(25 分)(坑比较多,a可能很大,a也有可能是负数,回头再看看)

    1009 Product of Polynomials (25)(25 分) This time, you are supposed to find A*B where A and B are two ...

  7. PAT甲 1009. Product of Polynomials (25) 2016-09-09 23:02 96人阅读 评论(0) 收藏

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  8. pat 甲级 1009. Product of Polynomials (25)

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  9. PATA 1009. Product of Polynomials (25)

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  10. 【PAT】1009. Product of Polynomials (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...

随机推荐

  1. 玩转X-CTR100 | STM32F4 l Malloc内存管理

    我造轮子,你造车,创客一起造起来!塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ]      内存管理技术,即内存的申请和释放,使用X- ...

  2. 2018-北航-面向对象第三次OO作业分析与小结

    1. 规格设计的发展历史 规格设计用于对程序设提供分解,抽象等的手段.在撰写代码规格的时候,需要对组成部件进行抽象. 在1960s,软件设计出现危机,例如Dijkstra提出了goto语句的种种危害, ...

  3. BitDefender(比特梵德)特惠活动 免费获取9个月激活码

    Bitdefender为了庆祝自己获得2014年最佳杀毒软件,送出9个月的Internet security免费激活码.

  4. 基于PHP+MYSQL的WEB聊天应用雏形开发实例教程

    更多技术资源:胡旭个人博客 前天,简单利用PHP做了一个简单的WEB聊天应用.没有发到网上,所以就不提供demo了.不过,发布一下源代码(见文尾). 项目说明: 基于PHP+MYSQL的WEB聊天应用 ...

  5. Magento邮件发送完美设置

    Magento新站上线伊始,不料在邮件上遇到了问题.此时常用的邮件模板已经编辑完毕,诸如New Account, New Order, Password Forget等. CentOS下发送邮件很简单 ...

  6. Python3下安装pip和MySQLdb

    MySQLdb的安装更曲折了.还是按照正常方法安装,下载MySQL-python-1.2.5版本,解压后python setup.py install,发现怎么装都会报错“ConfigParser.N ...

  7. BZOJ4836: [Lydsy1704月赛]二元运算【分治FFT】【卡常(没卡过)】

    Description 定义二元运算 opt 满足 现在给定一个长为 n 的数列 a 和一个长为 m 的数列 b ,接下来有 q 次询问.每次询问给定一个数字 c 你需要求出有多少对 (i, j) 使 ...

  8. test20181005 序列

    题意 考场30分 维护差值,考虑每次移动的变更,当前2-n位置上的差加1,1位置上的差减n-1. 然后要求的是绝对值的和,用吉司机线段树维护最大最小值.次大次小值. 期望复杂度\(O(n \log n ...

  9. ES6必知必会 (三)—— 数组和对象的拓展

    数组的扩展 1.拓展运算符('...'),它相当于rest参数的逆运算,用于将一个数组转换为用逗号分隔的参数序列: console.log(...[1, 2, 3]) // 1 2 3 console ...

  10. day9 python学习 文件的操作 读 写 seek

    文件的操作 1   文件的打开操作: 文件句柄 = open('文件路径', '模式') f=open('wangyakun','a+',encoding='utf-8') #文件名, 如果是绝对路径 ...