PAT 甲级 1009 Product of Polynomials

https://blog.csdn.net/a845717607/article/details/86530433

map使用:

声明:map<键,值> 变量名;

存储:

  1. scanf("%d %lf",&e,&coe);
  2.  mp1[e]=coe;

遍历:for(map<int,double>::iterator it=mp1.begin();it!=mp1.end();++it) 

逆序遍历:for(map<int,double>::reverse_iterator it=mp2.rbegin();it!=mp2.rend();++it)

PS.

  1. map内部自建一颗红黑树(一 种非严格意义上的平衡二叉树),这颗树具有对数据自动排序的功能,所以在map内部所有的数据都是有序的。
  2. 注意进位
if(mp2.count(it->first+e)==0)
                mp2[it->first+e]=it->second*coe;
            else
                mp2[it->first+e]+=it->second*coe;

 

posted @ 2020-10-30 17:23  ethon-wang  阅读(97)  评论(0编辑  收藏  举报