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 分)相关推荐

  1. PAT甲级1009 Product of Polynomials (25分)

    PAT甲级1009 Product of Polynomials (25分) 题目: 题目分析:和之前有一道多项式相加很像,注意点是不仅仅数组系数会变,还可能会出现之前没有的指数,因此要开2001大小 ...

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

  3. 【PAT甲级 多项式相乘】1009 Product of Polynomials (25 分) C++ 全部AC

    题目 思路 维护三个数组: arrA[1001]存储第一行数据 arrB[1001]存储第二行数据 c[1000000]存储计算结果 数组下标表示多项式的指数,数组存的内容表示多项式的系数 将arrA ...

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

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

  5. 【测试点0分析】1009 Product of Polynomials (25 分)

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 This time, you are supposed to find A×B where A and B are two pol ...

  6. 1009 Product of Polynomials (25 分)【难度: 简单 / 知识点: 模拟】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805509540921344 注意:系数数据范围虽然是0-1000 但是乘 ...

  7. PAT甲级1009 Product of Polynomials:[C++题解]多项式乘法、高精度乘法

    文章目录 题目分析 题目链接 题目分析 多项用一个数组来表示,数组下标表示多项式的次幂,存的内容表示多项式的系数. 然后用两重循环来计算多项式的乘法: for i : 第二个式子for j:第一个式子 ...

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

  9. 1009 Product of Polynomials (25)(25 分)

    题目 原题大意:求两个多项式的数乘 关键单词对照翻译如下: exponent 指数 coefficient 系数 polynomial 多项式 product 数乘 思路 最直接最快速的方法就是使用m ...

最新文章

  1. Spring Security快速上手
  2. python round函数_Python round() 函数
  3. Node 10 新功能概览(译)
  4. Scala函数简化写法
  5. [原创]Flex文本框自动提示(AutoSuggest)、自动完成(AutoComplete)
  6. 【hadoop】1.简介
  7. Oracle的列转行问题
  8. 实现标题条的显示与隐藏
  9. php程序内存空间,php如何管理内存
  10. 5G版iPhone更多细节曝光:骁龙X55基带+A14处理器
  11. ubuntu16.04安装python.h_ubuntu16.04安装python3.6踩过的坑
  12. hdu5414(2015多校10)--CRB and String(字符串匹配)
  13. 队列queue的详细讲解
  14. 8-3-无用单元收集-动态存储管理-第8章-《数据结构》课本源码-严蔚敏吴伟民版...
  15. 《Java就业培训教程》_张孝祥_书内源码_02
  16. 超详细Anaconda安装教程
  17. FTP下载文件夹到windows
  18. 你玩的英雄在比赛中发挥如何呢?
  19. 【python】鞭炮快乐响,春联贴门上,祝福送到你身旁
  20. 计算机应用基础心得体会300字,网络远程学习的心得体会

热门文章

  1. wxid转成微信账号
  2. Springboot 开发 Web Flux
  3. 华为 Linux 内核贡献者被质疑刷 KPI
  4. 未来农业发展可能面临的三大变化
  5. 第11課 受付の人は親切でした
  6. linux mmap详解
  7. 多媒体计算机常用的图像有哪些,在多媒体计算机中常见的图像输入设备是?
  8. UI培训分享:零基础学UI自学和报班哪个好
  9. 硬件电路设计--电子器件(二)
  10. 分布式链路调用Zipkin快速入门