多项式乘法

和多项式加法类似,参考之前多项式加法的代码改改就出来了。

主要是注意一下。最大次数应该会有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的更多相关文章

  1. 浙大pat1009题解

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  2. PAT1009:Product of Polynomials

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  3. pat1009. Product of Polynomials (25)

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

随机推荐

  1. Html5中的本地存储

    Web Storage web storage页面存储是html5为数据存储在客户端提供的一项重要功能,由于web storage API能够区分会话数据与长期数据.因此,相应API也分为两种: se ...

  2. 学习PHP函数:preg_match_all

    <?php $str = '10.10.10.10, 10.10.10.11'; preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', ...

  3. 解决ORA-00904: invalid identifier标识符无效

    方法/步骤 1 大部分情况下,此错误是由于引用了不存在的列名导致的.比如select name from Studtent 当studeng表中无name列时,系统就会报此错误. 2 解决思路是,确定 ...

  4. .project

    http://blog.csdn.net/qiushuichangtian888/article/details/9299843 一个老项目导入新环境后老是提示build.properties不存在的 ...

  5. SQL截取字符串

    SUBSTRING 返回字符.binary.text      或      image      表达式的一部分.有关可与该函数一起使用的有效      Microsoft®      SQL    ...

  6. spring 入门级程序示例

    public interface Action { public String execute(String str); } 接口 public class UpperAction implement ...

  7. C/C++ - 结构体实际申请的空间

    C/C++ - 结构体实际申请的空间 如下的结构体,sizeof()大小,实际申请的空间以及理论上申请最佳空间 struct Spot { int x; int y; bool visible; in ...

  8. How to write a probeContentType() and Usage?

    Files.probeContentType() is an instance of FileTypeDetector class's abstract method String FileTypeD ...

  9. 命令行从Android手机中导出已安装APK的方法调研

    一.背景 二.步骤 一.背景 很多时候,APK文件只存在于应用市场,在PC上无法直接下载.用手机下载下来后就直接安装了,也不能保存原始的APK文件. APK安装到手机后,Android系统会保存一份和 ...

  10. 快学Scala-第四章 映射和元组

    知识点: 1.构造映射,映射是对偶的集合 val scores1 = Map("Alice" -> 10, "Bob" -> 7, "Ci ...