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 ...
随机推荐
- Java学习---JAVA的类设计
基础知识 JAVA是由C/C++语言发展而来的纯面向对象语言,其基本元素包括:简单数据类型 和 复合数据类型(即类).类是对客观事物的抽象描述,它有面向对象的四个特点,即:封装性.继承性.多态性和通信 ...
- [BZOJ 1552] 排序机械臂
Splay大法是坠吼滴! 1552: [Cerc2007]robotic sort Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 436 Solved: ...
- 关于memcpy的实现
今天去面试,面试官出了一个关于memcpy的函数原型的实现的问题,本来这个问题是很简单的,但是不知道当时怎么脑子一抽竟然写错了,真是”累觉不爱”了.感觉这份工作算是泡汤了,算了事情发生了,错过了也就错 ...
- 【转】用JS创建json数据,并且可以动态往json数据里面添加新值,也可以修改值。
原文地址:http://blog.csdn.net/panlingfan/article/details/45562893/ 函数不需要 return,因为 json 对象会被函数直接修改. var ...
- javascript对象和函数的几种常见写法
/** * Created by chet on 15/12/17. */ var En= function (button,func) { //dosth,不能return alert(button ...
- 【bbs】login.php
require的路径 整体结构的复用 渐变效果的加入 按钮:实现背景透明,文字不透明:在background-color中使用rgba,标准浏览器中,背景透明,文字不透明background-colo ...
- 401. Binary Watch 回溯
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom ...
- ThinkPhp表单令牌和字段映射
开启表单令牌: 先在配置文件目录下定义tags.php 在里面添加 return array( 'view_filter' =>array('Behavior\TokenBuildBehavio ...
- How RTT works
13.2 How RTT works 13.2.1 Target implementation Real Time Terminal uses a SEGGER RTT Control Block s ...
- C#泛型约束 (转载)
六种类型的约束: T:结构 类型参数必须是值类型.可以指定除 Nullable 以外的任何值类型.有关更多信息,请参见使用可空类型(C# 编程指南). T:类 类型参数必须是引用类型,包括任何类.接口 ...