PAT甲级——1009 Product of Polynomials
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的更多相关文章
- 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 ...
- pat 甲级 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- 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 ...
- 【PAT】1009. Product of Polynomials (25)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
- 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 ...
- PAT甲级——A1009 Product of Polynomials
This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- promise核心技术 2.两种回调函数 js中error的处理
抽空详细学习一下什么是回调函数(一个回调函数,也被称为高阶函数) 1.什么样的函数是回调函数 自己定义的(sittimeout不是自己定义的) 没有调用 自己执行 1.同步回调与异步回调函数 同步回调 ...
- 第七届(16年)蓝桥杯java B组决赛真题 愤怒的小鸟 解题思路
愤怒小鸟 X星球愤怒的小鸟喜欢撞火车! 一根平直的铁轨上两火车间相距 1000 米两火车 (不妨称A和B) 以时速 10米/秒 相对行驶. 愤怒的小鸟从A车出发,时速50米/秒,撞向B车,然后返回去撞 ...
- Mdb文件工具类,UCanAccess使用,Access数据库操作
================================ ©Copyright 蕃薯耀 2020-01-09 https://www.cnblogs.com/fanshuyao/ 使用Ocbc ...
- django-blog:多对多查询
简单写一下多对多查询model 不是多对多的字段我就没写上来的 class Tag(models.Model): name = models.CharField(max_length=20,verbo ...
- VUE- iView组件框架的使用
VUE- iView组件框架的使用 1. 下载iView 工程. 引用:https://www.iviewui.com/
- 代码杂谈-or符号
看到别人的代码里用了 or, 有点巧用. 记录一下. def func(a,b, context=None): # .... ctx = context or global_context() # . ...
- 201771010123汪慧和《面向对象程序设计JAVA》第九周实验总结
一.理论部分 1.异常 (1)异常处理的任务就是将控制权从错误产生的地方转移给能够处理这种情况的错误处理器. (2)程序中可能出现的错误和问题:a.用户输入错误.b.设备错误.c.物理限制.d.代码错 ...
- 【论文笔记系列】AutoML:A Survey of State-of-the-art (下)
[论文笔记系列]AutoML:A Survey of State-of-the-art (上) 上一篇文章介绍了Data preparation,Feature Engineering,Model S ...
- php速成_day4
一.微信公众平台概述 1.微信发展史 1)2011年1月21日,腾讯推出微信应用程序.(张小龙) 2)2012年8月20日,腾讯推出微信公众平台功能,同年11月开放第三方接口 3)2013年11月注册 ...
- Exchange 2016 CU3 安装失败解决方法
Exchange 2016 CU3 安装失败解决方法 1. 问题: 由于前期安装过Exchange 2010 ,服务器非正常删除,后期人员无法跟进,在新安装Exchange 2016时准备工作正常完成 ...