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;
 }

最新文章

  1. C#和.net的版本
  2. 微信小程序-发起请求
  3. .net自动生成数据库表的类
  4. Oracle 存储过程包
  5. 【JMeter】Jmeter-完成一个http压力测试
  6. ☀【JS】eval
  7. mongodb 在windows上安装为服务
  8. 用sql增、修改、删除字段
  9. 读书笔记 effective c++ Item 39 明智而谨慎的使用private继承
  10. Jmeter 相关资源
  11. 《构建之法》教学笔记——Python中的效能分析与几个问题
  12. Batch入门教程丨第一章:部署与Hello World!(上)
  13. ElasticSearch 2 (9) - 在ElasticSearch之下(图解搜索的故事)
  14. 用CSS3制作尖角标签按钮样式
  15. DMA内存申请--dma_alloc_coherent 及 寄存器与内存【转】
  16. c#创建文件( File.Create() )后对文件写操作出错的分析
  17. php PDO mysql
  18. vs2015 活动解决方案或项目由选择的源代码管理插件以外的插件管理
  19. 04-python第四天学习
  20. linux系统启动过程及运行等级详解

热门文章

  1. pycharm和python安装
  2. POJ 1260:Pearls 珍珠DP
  3. c 转二进制
  4. 新iPhone上市会让富士康迎来新一轮的“用工荒”吗?
  5. 18 11 27 高级的服务器连接 epoll
  6. spark与Scala版本对应问题
  7. 【十日冲刺计划】第一日 星遇Sprint1计划会议成果
  8. 5.GIT使用问题
  9. JS基础——脚本位置、数据类型、函数作用域
  10. 寒假day12