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. js 数据

    非0数字值 都是true  0和NaN 都是false 任何对象   都是true  null       都是false undefined 不适用 详情

  2. POJ - 3658 Artificial Lake

    题意:向N个连续且高度不同的平台灌水,平台各有宽度,且高度各不相同.一开始,先向高度最低的平台灌水,直到灌满溢出,流向其他的平台,直至所有平台都被覆盖.已知每分钟注入高度为1且宽度为1的水,问每个平台 ...

  3. 合并排序_python

    #!/usr/bin/python # --coding:utf-8 -- def sort_merge(left,right): i,j=0,0 result=[] while i<len(l ...

  4. VEH&VCH

    本文99.9%的代码及内容作者:mengwuji 来自:http://www.mengwuji.net/forum.php?mod=viewthread&tid=1371 VEH:向量化异常处 ...

  5. lvm 逻辑卷分区删除恢复

    原因:执行 lvremove /dev/system/lv_trans 删除逻辑分区 恢复: 1.进入到lvm查看元数据 cd /etc/lvm/archive 2.恢复元vg卷组 vgcfgrest ...

  6. 实验吧web--易--后台登陆

    题目地址:http://www.shiyanbar.com/ctf/2036 这道题确实有点考研脑洞了. 1.首先,查看网页源代码(Ctrl+U),会发现一段PHP代码: $sql = "S ...

  7. windows 10 远程连接出现CredSSP加密Oracle修正错误

    以下方法只受用于windows专业版或者企业版 . 解决方法: 运行 gpedit.msc 本地组策略: 计算机配置>管理模板>系统>凭据分配>加密Oracle修正 选择启用并 ...

  8. Thread--停止线程

    参考:http://blog.sina.com.cn/s/blog_6ca570ed01016mti.html Thread.interrupt()方法不会中断一个正在运行的线程.它的作用是,在线程受 ...

  9. Java--类初始化

    package httpclient.demo; public class StaticTest { public static void main(String[] args) { staticFu ...

  10. canvas实现粒子星空连线

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>离 ...