PAT1009
2024-10-18 22:37:29
多项式乘法
和多项式加法类似,参考之前多项式加法的代码改改就出来了。
主要是注意一下。最大次数应该会有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 ;
}
最新文章
- [Spring] Spring配置文件中特殊字符的规定
- 电容参数:X5R,X7R,Y5V,COG 详解
- 变形--扭曲 skew()
- 5-1 源码包与RPM包的区别
- css实现居中
- 虚拟化之docker
- android 基本控件使用
- CSS3-loading动画(四)
- EffectiveJava阅读笔记(一)
- Dynamics 365中显示格式为URL的字段极少部分URL值录入了不显示怎么回事?
- 封装day.js
- POJ_1185_炮兵阵地 dp+状态压缩
- LeetCode高频148错题记录
- 【设计模式】jdbc桥连接过程解析
- Entity Framework DbSet<;T>;之Include方法与IQueryable<;T>;扩展方法Include的使用
- BZOJ 4004: [JLOI2015]装备购买
- WebService使用实例
- iOS调用第三方地图App进行导航方法
- Django的 admin管理工具
- 551. Student Attendance Record I
热门文章
- html/css技巧总结
- hdu_5727_Necklace(二分匹配)
- MQL5 获取最后一单 利润
- 5.如果第4题中在DOS命令下输入:java Hello 出现以下结果:Bad command or the file name 可能是什么原因?请说明理由。
- 3.请问配置JDK时环境变量path和JAVA_HOME的作用是什么?
- XHTML 与 HTML 之间的差异
- 自己开发的轻量级gif动画录制工具
- 【最短路】 poj 2387
- ReactiveX序列——RxSwift 浅析
- 新建aix实例