PATA1009 Product of Polynomials

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<cstdio>
#include<iostream>
#define max 2001
using namespace std;
struct Poly{
	int exp;
	double cof;
} poly[1001];
double ans[2001];

int main()
{
	int n,m,number=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d %lf",&poly[i].exp,&poly[i].cof);

	}
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		int exp;
		double cof;
		scanf("%d %lf",&exp,&cof);
		for(int j=0;j<n;j++)
		{
			ans[exp+poly[j].exp]+=(cof*poly[j].cof);
		}
	}
	for(int i=0;i<=2000;i++)
	{
		if(ans[i]!=0.0)
		{
			number++;
		 } 

	}
	cout<<number;
	for(int i =2000;i>=0;i--)
	{
		if(ans[i]!=0.0)
		{
			printf(" %d %.1lf",i,ans[i]);
		}
	}
	return 0;
 }

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

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

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

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

  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)

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

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

  6. PAT甲级——A1009 Product of Polynomials

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

  7. PAT——甲级1009:Product of Polynomials;乙级1041:考试座位号;乙级1004:成绩排名

    题目 1009 Product of Polynomials (25 point(s)) This time, you are supposed to find A×B where A and B a ...

  8. PAT 1009 Product of Polynomials

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

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

随机推荐

  1. Java语言概述-JavaSE

    代码虐我千百遍,我视代码如初恋 初级学习思想: 先了解Java 下载中英文文档对照学习 多看,多学 多敲,狂练 多标注注释 总结—创造 https://baike.baidu.com/(Java百度百 ...

  2. maven镜像仓库

    国内连接maven官方的仓库更新依赖库,网速一般很慢,收集一些国内快速的maven仓库镜像以备用. ====================国内OSChina提供的镜像,非常不错=========== ...

  3. 雅可比行列式【2】Jacobian行列式的意义

    2.1 线性变换将面积伸缩 对于一个\(\R^2\to\R^2\)的线性变换: \[ T(x,y)= \left[ \begin{array}{c} 4x-2y\\ 2x+3y \end{array} ...

  4. php封装一个接口类

    <?phpClass Response{//返回数据 public static function show($code,$message='',$data='',$type = 'json', ...

  5. Python—数据结构——链表

    数据结构——链表 一.简介 链表是一种物理存储上非连续,数据元素的逻辑顺序通过链表中的指针链接次序,实现的一种线性存储结构.由一系列节点组成的元素集合.每个节点包含两部分,数据域item和指向下一个节 ...

  6. Qt在vs2010下的配置

    https://blog.csdn.net/chenbang110/article/details/7607250 首先不要使用中文目录, 1 下载Qt的安装包和VS2010的Qt插件 2. 安装Qt ...

  7. TX2Ubuntu16.04上安装 kinectV2

    本文参考   https://www.ncnynl.com/archives/201706/1780.html 参考    https://blog.csdn.net/qq_33835307/arti ...

  8. 201609-1 最大波动 Java

    用绝对值,后一天减去前一天即可 import java.util.Scanner; public class Main { public static void main(String[] args) ...

  9. win10系统开发环境安装studio 3T(MongoDB桌面客户端)

    studio 3T 是mongodb优秀的桌面客户端工具. 下载 https://studio3t.com/download/#windows 本教程基于2020.1.2版本 安装 F:\javawe ...

  10. Docker 三剑客--Machine

    Machine 我们知道在多个集群服务环境下,安装管理Docker的容器,要使用的是Docker Swarm,而使用Docker Swarm的情况是在多个集群的服务器已经搭建好Docker环境的情况下 ...