PAT-A 1009. Product of Polynomials
参考:https://www.jianshu.com/p/e7a3ee0f82d9
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+;
double xi[N];
struct node
{
int zhi;//指数
double xi;//系数
}noa[],nob[];
int main()
{
int na,nb;
cin>>na;
for (int i=;i<na;i++)
{
cin>>noa[i].zhi;
cin>>noa[i].xi;
}
cin>>nb;
for (int i=;i<nb;i++)
{
cin>>nob[i].zhi;
cin>>nob[i].xi;
}
double tempxi;//临时系数
int tempzhi,nc=;//临时指数
for (int i=;i<na;i++)
{
for (int j=;j<nb;j++)
{
tempzhi=noa[i].zhi+nob[j].zhi;
tempxi=noa[i].xi*nob[j].xi;
// if (xi[tempzhi]==(double)0)//在计算过程中,某一指数项的系数有可能暂时为0后又不为0,所以不能用
// { //这段代码来计数!!
// nc++;
// }
xi[tempzhi]+=tempxi;
}
}
for (int i=N;i>=;i--)
{
if (xi[i]!=(double))
{
nc++;
}
}
cout<<nc;
for (int i=N;i>=;i--)
{
if (xi[i]!=(double))
{
printf(" %d %.1f",i,xi[i]);
}
}
cout<<endl; return ;
}
PAT-A 1009. Product of Polynomials的更多相关文章
- 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)(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
PATA1009 Product of Polynomials Output Specification: For each test case you should output the produ ...
- 【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 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 ...
- 1009 Product of Polynomials (25 分)
1009 Product of Polynomials (25 分) This time, you are supposed to find A×B where A and B are two pol ...
- PATA 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
随机推荐
- Linux kill/pkill/killall命令详解
kill kill(terminate a process)命令用来终止指定的进程, 对于一个后台进程就须用kill命令来终止,我们就需要先使用ps/pidof/pstree/top等工具获取进程PI ...
- Linux 配置samba服务实现与Windows文件共享
目录: 1.samba服务介绍 2. 安装samba服务和客户端 3.samba配置文件详解 4.配置实例 5.客户端挂载与测试 6.samba排错 1.Samba服务介绍 Samba 最先在 ...
- 一点二次插值、二点二次插值 ,matlab
syms f x a b c; f(x)=3*x^4-4*x^3-12*x^2; q(x)=a*x^2+b*x+c; %二点二次插值 x=[-1.2 -0.8]; ff=diff(diff(f)); ...
- 离散对数&&大步小步算法及扩展
bsgs algorithm ax≡b(mod n) 大步小步算法,这个算法有一定的局限性,只有当gcd(a,m)=1时才可以用 原理 此处讨论n为素数的时候. ax≡b(mod n)(n为素数) 由 ...
- [POI2015]LOG
题目 发现询问是针对整个区间,也就是说位置什么用都没有 发现我们需要构造出\(s\)个长度为\(c\)的数列,每个数只能在一个数列中出现一次,且一个数最多的使用次数是其大小 对于那些大于等于\(s\) ...
- Django重定向的写法、与直接渲染的区别
Django重定向的写法.与直接渲染的区别 return redirect (“login”) #重定向到login页面,状态码是302页面重定向和直接渲染新的页面的区别.重定向实际是指向了另 ...
- Sublime Text 3中设置不记住上次打开的文件
转自:https://blog.csdn.net/nicholaszao/article/details/79575251 在”User/Preferences.sublime-settings”配置 ...
- spring中的default-lazy-init参数和lazy-init
在spring的配置中的根节点上有个 default-lazy-init="true"配置: 1.spring的default-lazy-init参数 此参数表示延时加载, ...
- SOE 部署错误 ClassFactory cannot supply requested class问题及解决方案
一.问题描述 虽然SOE开发已经老早出来了(ArcGIS 10.1 不再支持DCOM开发,所以以往的基于AO+WebService需要转变思路),不过由于跟工作关联性不是很大,一直未系统学习过.网上下 ...
- 推荐一个WPF仪表盘开源控件
前段时间,做服务器端监控系统,为了界面好看,采用WPF.硬件相关监控,比如CPU.内存等,想用仪表盘控件.网上找了很多这种控件,基本上都是第三方商业控件(虽然很漂亮,不过得money...).最后在C ...