PATA1009 Product of Polynomials
【摘要】
PATA1009 Product of Polynomials
Output Specification: For each test case you should output the pro...
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
- 1
- 2
- 3
Sample Output:
3 3 3.6 2 6.0 1 1.6
- 1
- 2
#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
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
文章来源: blog.csdn.net,作者:沧夜2021,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/CANGYE0504/article/details/88827927
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)