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