• 1009_Product of Polynomials (25分)[模拟]


     1 #include<iostream>
     2 #include<vector>
     3 #include<queue>
     4 #include<map>
     5 #include<set>
     6 #include<cmath>
     7 #include<cstdio>
     8 #include<cstdlib>
     9 #include<cstring>
    10 #include<algorithm>
    11 using namespace std;
    12 const int  maxLen = 1000 + 10;
    13 
    14 int K, maxRes, maxN, p;//maxNum记录结果的最大次数
    15 double N[maxLen], res[maxLen * maxLen], pVal;
    16 
    17 int main()
    18 {
    19     memset(N, 0, sizeof(N));
    20     memset(res, 0, sizeof(res));
    21     maxN = maxRes = 0; 
    22     map<int, double> map;
    23 
    24     cin >> K;
    25     for (int i = 0; i < K; i++) {
    26         cin >> p;
    27         cin >> N[p];
    28         maxN = max(maxN, p);
    29     }
    30 
    31     cin >> K;
    32     for (int i = 0; i < K; i++) {
    33         cin >> p >> pVal;
    34         for (int i = 0; i <= maxN; i++) {
    35             if (N[i] != 0) {
    36                 res[i + p] += N[i] * pVal;
    37                 maxRes = max(maxRes, i + p);
    38             }
    39         }
    40     }
    41     for (int i = maxRes; i >= 0; i--) {
    42         if (res[i] != 0) {
    43             map[i] = res[i];
    44         }
    45     }
    46     cout << map.size();
    47     for (auto iter = map.rbegin(); iter != map.rend(); iter++) {
    48         printf(" %d %.1lf", iter->first, iter->second);
    49     }
    50     return 0;
    51 }
  • 相关阅读:
    五一集训——图论
    Luogu P3942 将军令
    8.14 Round 1
    8.10 Round 1
    8.9 Round 1
    8.7 Round 2
    8.7 Round 1
    8.6 Round 1
    8.5 Round 2
    FHQ-Treap
  • 原文地址:https://www.cnblogs.com/NiBosS/p/12104992.html
Copyright © 2020-2023  润新知