2 条题解

  • 0
    @ 2024-7-22 8:35:26
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        freopen("mul.in", "r", stdin);
        freopen("mul.out", "w", stdout);
        
        vector<int> a(11, 0), b(11, 0), r(21, 0);
        
        for (int i = 0; i < 2; i++) {
            int c, p;
            cin >> c >> p;
            a[p] += c;
        }
    
        for (int i = 0; i < 2; i++) {
            int c, p;
            cin >> c >> p;
            b[p] += c;
        }
    
        for (int i = 0; i <= 10; i++) {
            for (int j = 0; j <= 10; j++) {
                r[i + j] += a[i] * b[j];
            }
        }
    
        for (int i = 20; i >= 0; i--) {
            if (r[i] != 0) {
                cout << r[i] << " " << i << endl;
            }
        }
        
        return 0;
    }
    
    • -1
      @ 2023-11-5 11:45:08

      数组下标表示幂次数,元素的值表示系数。 其中,幂次数相加,用一个数组的下标表示。系数相乘,储存在name[幂次方]中。

      #include<iostream>
      #include<cstdio>
      #define O 164;
      using namespace std;
      int a[2][2],b[2][2],name[101];
      int main(){
          freopen("mul.in","r",stdin);
          freopen("mul.out","w",stdout);
          for(int t=0;t<2;t++){
              for(int i=0;i<2;i++){
                  cin>>a[t][i];
              }
          }
          for(int t=0;t<2;t++){
              for(int i=0;i<2;i++){
                  cin>>b[t][i];
              }
          }
          for(int t=0;t<2;t++){
              for(int i=0;i<2;i++){
                  name[a[t][1]+b[i][1]] += a[t][0]*b[i][0];
              }
          }
          for(int t=100;t>=0;t--){
              if(name[t]==0){
                  continue;
              }
              cout<<name[t]<<" "<<t<<endl;
          }
          return O;
      }
      
      • 1

      信息

      ID
      167
      时间
      1000ms
      内存
      256MiB
      难度
      7
      标签
      (无)
      递交数
      132
      已通过
      27
      上传者