PAT1009
多项式乘法
和多项式加法类似,参考之前多项式加法的代码改改就出来了。
主要是注意一下。最大次数应该会有1000000,然后按照乘法规则来,分配率就没有问题
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<string.h> using namespace std; float maps[];
float mapss[]; int main()
{
int n,x;
float y,aa;
int aN=;
cin>>n;
while (n--)
{
cin>>x>>y;
maps[x] = y;
}
cin>>n;
while (n--)
{
cin>>x>>y;
for (int i = ; i >= ; i--)
{
aa=mapss[x+i];
mapss[x+i] += maps[i] * y;
if(aa == && mapss[x+i] != )
aN++;
else if(aa != && mapss[x+i] == )
aN--;
}
}
if(aN == )
{
cout<<aN;
return ;
}
else
{
cout<<aN<<" ";
}
for (int i = ; i >= ; i--)
{
if(aN == && mapss[i] != )
{
printf("%d %.1f",i,mapss[i]);
break;
}
else if(mapss[i] != )
{
printf("%d %.1f ",i,mapss[i]);
aN--;
}
}
return ;
}
PAT1009的更多相关文章
- 浙大pat1009题解
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- PAT1009:Product of Polynomials
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- pat1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
随机推荐
- 《初识PE》导入表
最近听别人讲的我晕晕乎乎的,于是上网上百度下,感觉这篇还不错. 链接:http://www.blogfshare.com/pe-export.html 一.导入表简介 在编程中常常用到"导 ...
- POJ 2387 Til the Cows Come Home(dij+邻接矩阵)
( ̄▽ ̄)" //dijkstra算法: //这题建邻接矩阵的时候有坑(先读入边后读入点),还有重边: #include<iostream> #include<cstdio ...
- iOS 的 APP 如何适应 iPhone 5s/6/6Plus 三种屏幕的尺寸?
初代iPhone 2007年,初代iPhone发布,屏幕的宽高是 320 x 480 像素.下文也是按照宽度,高度的顺序排列.这个分辨率一直到iPhone 3GS也保持不变. 那时编写iOS的App( ...
- jquery多级下拉菜单
var menu = new Click('#menu',{target:'p',parent:'li',contr:'ul',way:0}); /* 参数说明: target : 点击事件发生在该元 ...
- LVS负载均衡中arp_ignore和arp_annonuce参数配置的含义
先简单的介绍下关于LVS负载均衡 LVS(Linux Virtual Server)Linux服务器集群系统 针对高可伸缩,高可用服务的需求,给予IP层和内容请求分发的负载均衡调度解决方法,并在Li ...
- AJAX 在手机上用时
Response.ContentType = "text/html; text/plain; charset=UTF-8";
- VS2008 安装后没有模板
VS2008 安装过程没有任何报错 启动VS2008,新建项目时就成了这样,没有任何模板: 解决方法: 开始 –> 程序 –> Microsoft Visual Studio 2008– ...
- 转 Oracle DBCA高级玩法:从模板选择、脚本调用到多租户
但凡是学过Oracle的同学,对DBCA(Database Configuration Assistant, DBCA)都不会陌生,有了这个工具,使得创建数据库成为可能.而DBCA本身有图形和静默两种 ...
- Dockerfile编写语法
docker镜像本质上就是一个个基础镜像的堆叠,为了做出我们想要的镜像,我们需要考虑最终镜像所需的所有基础环境,然后一层层堆叠.也就是不断以基础镜像搭建上层镜像. 先看例子: # Version: # ...
- iOS NSMutableArray添加NSInteger元素
NSMutableArray *array = [[NSMutableArray alloc] init]; NSInteger num = 7; NSNumber *number = [NSNumb ...