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​​​​ (,) are the exponents and coefficients, respectively. It is given that 1, 0.

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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxnum 100005 double a[] = {};
double b[] = {};
double c[maxnum] = {}; int main(){
int n;cin >> n;
int t;
for(int i=;i < n;i++){
int x;double y;
cin >> x >> y;
a[x] = y;
if(!i)t = x;
}
int m;cin >> m;
int start;
for(int i=;i < m;i++){
int x;double y;
cin >> x >> y;
b[x] = y;
if(!i) start = x;
} for(int i=;i < t+;i++){
for(int j=;j < start+;j++){
c[i+j] += a[i]*b[j];
}
} int cnt = ;
for(int i=;i < maxnum;i++)if(c[i])cnt++;
cout << cnt; for(int i=maxnum-;i>=;i--){
if(c[i]) printf(" %d %.1lf",i,c[i]);
} return ;
}

空间开的有点小炸,做了一下优化就好了,再一次理解错了提议,K<10,不一定就项系数<10,还好这题没出毒瘤卡边界数据,在超过1e5的地方直接放弃了。。

 

PAT 1009 Product of Polynomials的更多相关文章

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

  2. PAT 1009 Product of Polynomials 模拟

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

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

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

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

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

  6. PTA (Advanced Level) 1009 Product of Polynomials

    1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomial ...

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

  8. PATA 1009. Product of Polynomials (25)

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

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

随机推荐

  1. Latex citation using natbib and footnotesize

    References: Natbib bibliography styles How to change font size for bibliography? Latex citation usin ...

  2. 使用p4c将P4 14代码转换为16代码

    参考: [Question] How to make conversion between P4 14 and P4 16? 使用p4c将P4 14代码转换为16代码: $ p4test --p4v ...

  3. Xilinx_ISE 14.7 Win10 闪退

    打开D:\Xilinx\14.7\ISE_DS\ISE\lib\nt64 将libPortabilityNOSH.dll 重命名为libPortability.dll,替换原libPortabilit ...

  4. mybatis(错误一) 项目启动时报“Result Maps collection already contains value forxxx”的解决方案

    Result Maps collection already contains value for xyx.dsw.dao.mapper.admin.quotationwish.TempTestTab ...

  5. 字符串函数 mysql 和sqlserver 中对于字符串的常用函数和区别

    1. 对于字符串大小写的统一 mysql和sqlserver中都有同名函数lower()和upper(),但是mysql中还有另外一对函数,达到同样的目的,lcase()和ucase(),也就是英文中 ...

  6. mysql基本知识总结

    第一天 create database act_web character set utf8; : 创建数据库并设立编码(命令中是不允许使用“-”的) '; :创建用户并设立密码 grant all ...

  7. [工具]cmd命令大全

    cmd命令大全(第一部分) winver---------检查Windows版本  wmimgmt.msc----打开windows管理体系结构(WMI)  wupdmgr--------window ...

  8. npm ERR! missing script: dev 报错解决

    npm run dev 报错:missing script:dev 今天在运行Vue项目时,在运行npm  run dev时报错如下图: 打开package.js文件夹,发现文件夹里的scripts有 ...

  9. sort-选择排序

    void sort_select(vector<int> &v) { for(int i=0;i<v.size()-1;i++) { int min=v[i]; int in ...

  10. Codeforces 797B - Odd sum

    B. Odd sum 题目链接:http://codeforces.com/problemset/problem/797/B time limit per test 1 second memory l ...