1009. Product of Polynomials (25)
来源:互联网 发布:java代码实现单例模式 编辑:程序博客网 时间:2024/04/30 02:40
#include<iostream>#include<map>#include<iomanip>using namespace std;bool compare(int i,int j){ return i>j;}int main(){ map<int,double,bool (*)(int i,int j)> map1(compare); map<int,double,bool (*)(int i,int j)> map2(compare); map<int,double,bool (*)(int i,int j)> map3(compare); int N; int m; double n; cin>>N; for(int t=0;t<N;t++) { cin>>m>>n; map1[m]=n; } cin>>N; for(int t=0;t<N;t++) { cin>>m>>n; map2[m]=n; } for(map<int,double,bool (*)(int i,int j)>::iterator it1=map1.begin();it1!=map1.end();it1++) for(map<int,double,bool (*)(int i,int j)>::iterator it2=map2.begin();it2!=map2.end();it2++) { map3[(it1)->first+(it2)->first]+=(it1)->second*(it2)->second; } for(map<int,double,bool (*)(int i,int j)>::iterator iter=map3.begin();iter!=map3.end();iter++) { if(iter->second==0) map3.erase(iter); } cout<<map3.size(); for(map<int,double,bool (*)(int i,int j)>::iterator iter=map3.begin();iter!=map3.end();iter++) { cout<<fixed<<setprecision(1)<<" "<<iter->first<<" "<<iter->second; } cout<<endl;}
0 0
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- PAT_1017. Queueing at Bank
- 阿里云Centos7.2搭建java开发环境 jdk tomcat mysql注意事项
- 1008 Elevator (20)
- MAVEN 编译spring boot + mybatis 出现 Error parsing Mapper XML.
- COM---类厂
- 1009. Product of Polynomials (25)
- java中实现多态的机制是什么?
- 微信小程序发布一个月,世界并没有什么不同
- 发现一个比较好的库: com.google.common.base
- AsyncHttp使用的一些坑
- 1012. The Best Rank (25)
- [BZOJ1036][ZJOI2008]树的统计Count(树链剖分)
- Gsonformat
- 1013. Battle Over Cities (25)