2 条题解

  • 1
    @ 2025-9-4 21:09:49
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        // 直接用数组映射难度数字到比例,索引即难度数字
        double ratio[11] = {0.0};
        ratio[2] = 0.4; ratio[3] = 0.5; ratio[4] = 0.6;
        ratio[6] = 0.7; ratio[7] = 0.8; ratio[9] = 0.9; ratio[10] = 1.0;
    
        int T;
        cin >> T;
        while (T--) {
            int m;
            cin >> m;
            double total = 0.0;
            for (int i = 0; i < m; i++) {
                char op;
                cin >> op;
                if (op == 'A') {
                    int x;
                    cin >> x;
                    total += (x <= 10) ? x : (x % 10) * 10;
                } 
                else if (op == 'B') {
                    int n, c;
                    cin >> n >> c;
                    // B 操作整数部分先算好,最后 floor
                    double coins = floor(ratio[n] * 50.0 * c * 0.1);
                    total += coins;
                } 
                else { // C 操作
                    int n, c;
                    cin >> n >> c;
                    total += ratio[n] * 20.0 * c * 0.01;
                }
            }
            cout << fixed << setprecision(2) << total << '\n';
        }
        return 0;
    }
    
    
    • 0
      @ 2025-9-13 11:03:39
      #include <bits/stdc++.h>
      using namespace std;
      
      int main() {
          ios::sync_with_stdio(false);
          cin.tie(nullptr);
      
          // 难度比例表
          unordered_map<int, double> ratio = {
              {2, 0.4}, {3, 0.5}, {4, 0.6},
              {6, 0.7}, {7, 0.8}, {9, 0.9}, {10, 1.0}
          };
      
          int T;
          cin >> T;
          while (T--) {
              int m;
              cin >> m;
              double total = 0.0;
              for (int i = 0; i < m; i++) {
                  char op;
                  cin >> op;
                  if (op == 'A') {
                      int x;
                      cin >> x;
                      if (x >= 1 && x <= 10) total += x;
                      else total += (x % 10) * 10;
                  } 
                  else if (op == 'B') {
                      int n, c;
                      cin >> n >> c;
                      total += ratio[n] * 50 * c * 0.1;
                  } 
                  else if (op == 'C') {
                      int n, c;
                      cin >> n >> c;
                      total += ratio[n] * 20 * c * 0.01;
                  }
              }
              cout << fixed << setprecision(2) << total << "\n";
          }
          return 0;
      }
      
      • 1

      信息

      ID
      1665
      时间
      1000ms
      内存
      256MiB
      难度
      10
      标签
      递交数
      29
      已通过
      3
      上传者