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 ...
随机推荐
- centos装openoffice
一.安装openOffice1.使用tar -xzvf OOo_3.2.0_LinuxIntel_install_wJRE_en-US.tar.gz解压缩后,会得到OOO320_m12_native_ ...
- node.js作为“简单HTTP服务器”
场景 当我学习一个JavaScript库的时候,需要一个非常简单的HTTP服务器把当前工作路径变为网站根目录,由此来访问网页的静态信息.现在,除了下边的脚本server.js,假设你已经拥有: 一个工 ...
- apache: 503
Any connection over Max, will get a 503 Service Temporarily Unavailable. 503出现的场景:压测url时,发现大量的503错误. ...
- android studio导入包后无法import
android studio导入jar包的方法: 1.将jar包放到module的libs目录下 2.在所导入的jar包上右键,选择“Add as library”. 其中,第二点跟eclipse不同 ...
- Lvs+Keepalived+Bind+web构建高可用负载均衡系统
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://hatech.blog.51cto.com/8360868/1417899 --- ...
- 笨方法学python--变量和命名
1 =(单等号)和==(双等号)的区别 =用来赋值, ==用来判断是否相等 2 x = 100 在操作符2侧加空格,易读 3 打印时,进行字符串拼接 print "there are&quo ...
- C#生成随机汉字
using System; using System.Text; namespace ConsoleApplication { class ChineseCode { ...
- Sublime console installation instructions install Package Control
instructions: import urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1 ...
- springmvc+mybatis下载项目自带模板
1.首先如果要获取javaweb项目中的文件在哪,用到的代码:request.getSession().getServletContext().getRealPath("/WEB-INF/d ...
- 解决编译时出现的警告:format string is not a string literal (potentially insecure)
NSLog([NSString stringWithFormat:@"%@/%@B.jpg", createDir, uuid]);//这是我的写法 应该写成 NSString * ...