PAT(Advanced) 1009 Product of Polynomials(25 分)
2018.9.6
// 注意:一定要计算map中非0的个数,而不能用map.size();#include <iostream>
#include <cstdio>
#include <map>
using namespace std;map<int, double> poly1, poly;int main(){int n;cin >> n;int cf, cf2;double xs, xs2;for(int i = 0; i < n; i++){cin >> cf >> xs;poly1[cf] = xs;}cin >> n;map<int, double>::iterator it;map<int, double>::reverse_iterator rit;for(int i = 0; i < n; i++){cin >> cf >> xs;for(it = poly1.begin(); it != poly1.end(); it++){cf2 = (it->first) + cf;xs2 = (it->second) * xs;poly[cf2] += xs2;}}int cnt = 0;for(it = poly.begin(); it != poly.end(); it++){if(it->second != 0)cnt++;}cout << cnt;for(rit = poly.rbegin(); rit != poly.rend(); rit++){if(rit->second == 0)continue;cout << ' ' << rit->first << ' ';printf("%.1lf", rit->second);}cout << endl;return 0;
}
PAT(Advanced) 1009 Product of Polynomials(25 分)相关推荐
- PAT甲级1009 Product of Polynomials (25分)
PAT甲级1009 Product of Polynomials (25分) 题目: 题目分析:和之前有一道多项式相加很像,注意点是不仅仅数组系数会变,还可能会出现之前没有的指数,因此要开2001大小 ...
- PAT甲级 -- 1009 Product of Polynomials (25 分)
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 分) C++ 全部AC
题目 思路 维护三个数组: arrA[1001]存储第一行数据 arrB[1001]存储第二行数据 c[1000000]存储计算结果 数组下标表示多项式的指数,数组存的内容表示多项式的系数 将arrA ...
- 【PAT】1009. Product of Polynomials (25)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
- 【测试点0分析】1009 Product of Polynomials (25 分)
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 This time, you are supposed to find A×B where A and B are two pol ...
- 1009 Product of Polynomials (25 分)【难度: 简单 / 知识点: 模拟】
https://pintia.cn/problem-sets/994805342720868352/problems/994805509540921344 注意:系数数据范围虽然是0-1000 但是乘 ...
- PAT甲级1009 Product of Polynomials:[C++题解]多项式乘法、高精度乘法
文章目录 题目分析 题目链接 题目分析 多项用一个数组来表示,数组下标表示多项式的次幂,存的内容表示多项式的系数. 然后用两重循环来计算多项式的乘法: for i : 第二个式子for j:第一个式子 ...
- 【PAT - 甲级1009】Product of Polynomials (25分)(模拟,细节)
题干: This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: ...
- 1009 Product of Polynomials (25)(25 分)
题目 原题大意:求两个多项式的数乘 关键单词对照翻译如下: exponent 指数 coefficient 系数 polynomial 多项式 product 数乘 思路 最直接最快速的方法就是使用m ...
最新文章
- Spring Security快速上手
- python round函数_Python round() 函数
- Node 10 新功能概览(译)
- Scala函数简化写法
- [原创]Flex文本框自动提示(AutoSuggest)、自动完成(AutoComplete)
- 【hadoop】1.简介
- Oracle的列转行问题
- 实现标题条的显示与隐藏
- php程序内存空间,php如何管理内存
- 5G版iPhone更多细节曝光:骁龙X55基带+A14处理器
- ubuntu16.04安装python.h_ubuntu16.04安装python3.6踩过的坑
- hdu5414(2015多校10)--CRB and String(字符串匹配)
- 队列queue的详细讲解
- 8-3-无用单元收集-动态存储管理-第8章-《数据结构》课本源码-严蔚敏吴伟民版...
- 《Java就业培训教程》_张孝祥_书内源码_02
- 超详细Anaconda安装教程
- FTP下载文件夹到windows
- 你玩的英雄在比赛中发挥如何呢?
- 【python】鞭炮快乐响,春联贴门上,祝福送到你身旁
- 计算机应用基础心得体会300字,网络远程学习的心得体会