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 ...
随机推荐
- 洛谷 P1964 【mc生存】卖东西(多重背包)
题目传送门 解题思路: 题目里有,多重背包. AC代码: #include<iostream> #include<cstdio> #include<map> usi ...
- MySQL表的几个简单查询语句
1. 创建数据库CREATE DATABASE database-name 2. 删除数据库drop database dbname 3. 创建新表create table tabname(co ...
- webview HttpClient 怎么保持会话session统一
cookies session均为key---value的形式展示, 1. session是存储在服务端,并有一块区域控件存储用户信息,主要是为了判断该用户是否登录,在客户端采用httpC ...
- MySQL硬核干货:从磁盘读取数据页到缓冲池时,免费链表有什么用?
1.数据库启动的时候,是如何初始化Buffer Pool的? 现在我们已经搞明白一件事儿了,那就是数据库的Buffer Pool到底长成个什么样,大家想必都是理解了 其实说白了,里面就是会包含很多个缓 ...
- (转)绝对路径${pageContext.request.contextPath}用法及其与web.xml中Servlet的url-pattern匹配过程
以系统的一个“添加商品”的功能为例加以说明,系统页面为add.jsp,如图一所示: 图一 添加商品界面 系统的代码目录结构及add.jsp代码如图二所示: 图二 系统的代码目录结构及add.js ...
- 磁盘报No space left on device,但是 df -h 查看磁盘空间没满
df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/dev01-root 75G 58G 14G 82% / udev 2.0G ...
- vue 动画原理 part1
Vue动画原理 增加和删除css增加样式实现一个过渡效果也就是动画效果 1.需要动画效果的标签外包裹一个transition标签 会被自动分析css样式,然后自动构建一个动画流程 transition ...
- 36. docker swarm docker secret 的使用和管理
1.secret management 的作用 用来存储 其他人不想看到 的数据 2.secret management 存在 swarm manager 节点 raft database 里. se ...
- Paper Review: Epigenetic Landscape, Cell Differentiation 02
I'll share another review paper about Epigenetic Landscape, it comes from Nature Review, published i ...
- 吴裕雄--天生自然ShellX学习笔记:Shell 函数
linux shell 可以用户定义函数,然后在shell脚本中可以随便调用. shell中函数的定义格式如下: [ function ] funname [()] { action; [return ...