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 N1 aN1 N2 aN2 ... NK aNK
where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1,2,⋯,K) are the exponents and coefficients, respectively. It is given that 1≤K≤10, 0≤NK<⋯<N2<N1≤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 分)的更多相关文章
- 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 ...
- 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 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 ...
- 【PAT甲级】1009 Product of Polynomials (25 分)
题意: 给出两个多项式,计算两个多项式的积,并以指数从大到小输出多项式的指数个数,指数和系数. trick: 这道题数据未知,导致测试的时候发现不了问题所在. 用set统计非零项时,通过set.siz ...
- 1009 Product of Polynomials (25分) 晚上脑子就是容易僵住
#include<iostream> using namespace std; struct { int a; double b; }poly[1001]; double a[2001]; ...
- 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 ...
- 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 ...
- pat 甲级 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- PATA 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- 【PAT】1009. Product of Polynomials (25)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
随机推荐
- ASP.NET下跨应用共享Session和使用Redis进行Session托管
在之前的博客中,我说到了Session的共享问题,其中说到了Web Farm和Web Garden两种情况下Session的处理.在ASP.NET提供的Session处理方法中,有以下四种模式: 1. ...
- Dev GridView-Bind Detail Grid during runtime
Here is a simple example. ASPX <%@ Page Language="C#" AutoEventWireup="true" ...
- reboot 后 Docker服务及容器自动启动设置
https://blog.csdn.net/wxb880114/article/details/82904765 重启reboot操作系统后,发现docker 服务未启动,容器也未启动,天生反骨,怎么 ...
- Engineering Management
Engineering Management 工程師面對工作或挑戰時,可應用以下法則一步一步把工作規管和實施. 1. Planning 計劃 2. Organization 組織 ...
- shell_exec
shell_exec — Execute command via shell and return the complete output as a string: <?php$output = ...
- IP addresses in C#
在.Net网络库里面最大的优点就是IP地址和端口被成对处理,相比于UNIX中用的方法真是一个巨大的令人欢迎的进步..NET定义了两个类来处理关于IP地址的问题. One of the biggest ...
- Objective-C和Swift混合编程开发
创建混编的Framework工程 第一步:创建target为Framework的工程 打开Xcode6-Beta,菜单栏File—>New—>Project; 创建一个新的工程,工程模板选 ...
- FW: Solving SharePoint Server -503. The service is unavailable, After installation
Installed: SharePoint Server 2010 for Internet Enterprise Beta (x64) On: Windows Server 2008 Standar ...
- 第二篇 makefile的基本结构
makefile用于定义并描述源文件之间的依赖关系,用于说明如何编译各个源文件并生成最终的可执行文件,规则是makefile中的基本组成部分. 一个最基本的依赖规则如下所示: targets代表这个规 ...
- HTML5和CSS3阶段,我是如何学习的?
经过一个月的学习,我收获了许多,今天的测验是做一个企业中文网站,令我自己感到吃惊的是,我前前后后用了4个小时就完成了,这在一个月前根本不可能,因为对布局属性的理解还不够深刻,常常会在调试中浪费大量时间 ...