【Java项目总结】设计阶段提高项目的拓展性

Docker分层打镜像

  返回  

1009 Product of Polynomials (25 point(s)) C++ 测试点0

2021/8/21 21:33:35 浏览:

注意:系数相加为零的要舍去,否则Case 0:Wrong Answer

#include<cstdio>
#include<map>
using namespace std;

int main(void){
    int K, N;
    float a;
    map<int, float> p1, p2, m;
    
    scanf("%d", &K);
    for(int i = 0; i < K; i++){scanf("%d %f", &N, &a); p1[N] += a;}
    scanf("%d", &K);
    for(int i = 0; i < K; i++){scanf("%d %f", &N, &a); p2[N] += a;}
    
    for(auto it1 = p1.begin(); it1 != p1.end(); it1++)
        for(auto it2 = p2.begin(); it2 != p2.end(); it2++){
            int n = it1->first + it2->first;
            m[n] += it1->second * it2->second;
            if(m[n] == 0) m.erase(n);
        }
    
    printf("%d", m.size());
    for(auto it = m.rbegin(); it != m.rend(); it++)
        printf(" %d %.1f", it->first, it->second);
    
    return 0;
}

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号