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 ...
随机推荐
- iOS自动化-iOS录屏xrecord及解决iPhone设备不显示的问题
github地址:https://github.com/WPO-Foundation/xrecord 安装方法: git clone https://github.com/WPO-Foundation ...
- 3、Python文件操作工具 xlwt 工具
# _*_ encoding:utf-8 _*_ import xlrdimport xlwt #新建excel文件excel = xlwt.Workbook(encoding='utf-8')#添加 ...
- JS实现键盘监听(包括组合键)
依然使用案例驱动~案例是学习的最好实践! <html> <head> <meta http-equiv="Content-Type" co ...
- TCP传输层协议的流程
http://blog.chinaunix.net/uid-24399976-id-77905.html 通过对互联网的认识,我们发现TCP传输层协议是网络进行工作的核心也是基础.它的重要性我们在此也 ...
- Maven经常使用命令
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/UP19910522/article/details/25985021 Maven库: http:// ...
- mongd配置文件解释
mongd配置文件解释 系统日志配置 systemLog: verbosity: <int> quiet: <boolean> traceAllExceptions: < ...
- Eclipse导入web项目发布项目时报Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web错误解决方案
Eclipse导入web项目后,将web项目加载到server进行发布时,提示Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java ...
- 通过css使文字有渐变的效果
<style> .color{ background-image: -webkit-gradient(linear, left center, right center, from(rgb ...
- java 静态相关内容
一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的;需要在项目启动的时候就初始化,在不创建对象的情况下,其他程序来调用的时候,需要使用静态方法,这种代码 ...
- 该网页已屏蔽以下插件Adobe Flash Player
2017.6.9更新:多谢网友留言,该网页已屏蔽以下插件Adobe Flash Player解决方法:chrome://flags/#run-all-flash-in-allow-mode选择启用就O ...