多项式乘法

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

主要是注意一下。最大次数应该会有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 ;
}

最新文章

  1. [Spring] Spring配置文件中特殊字符的规定
  2. 电容参数:X5R,X7R,Y5V,COG 详解
  3. 变形--扭曲 skew()
  4. 5-1 源码包与RPM包的区别
  5. css实现居中
  6. 虚拟化之docker
  7. android 基本控件使用
  8. CSS3-loading动画(四)
  9. EffectiveJava阅读笔记(一)
  10. Dynamics 365中显示格式为URL的字段极少部分URL值录入了不显示怎么回事?
  11. 封装day.js
  12. POJ_1185_炮兵阵地 dp+状态压缩
  13. LeetCode高频148错题记录
  14. 【设计模式】jdbc桥连接过程解析
  15. Entity Framework DbSet&lt;T&gt;之Include方法与IQueryable&lt;T&gt;扩展方法Include的使用
  16. BZOJ 4004: [JLOI2015]装备购买
  17. WebService使用实例
  18. iOS调用第三方地图App进行导航方法
  19. Django的 admin管理工具
  20. 551. Student Attendance Record I

热门文章

  1. html/css技巧总结
  2. hdu_5727_Necklace(二分匹配)
  3. MQL5 获取最后一单 利润
  4. 5.如果第4题中在DOS命令下输入:java Hello 出现以下结果:Bad command or the file name 可能是什么原因?请说明理由。
  5. 3.请问配置JDK时环境变量path和JAVA_HOME的作用是什么?
  6. XHTML 与 HTML 之间的差异
  7. 自己开发的轻量级gif动画录制工具
  8. 【最短路】 poj 2387
  9. ReactiveX序列——RxSwift 浅析
  10. 新建aix实例