2 条题解

  • 1
    @ 2026-6-13 13:56:51
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int T;
        cin >> T;
    
        cout << fixed << setprecision(3);
    
        while (T--) {
            double V, Tm, T0, L;
            cin >> V >> Tm >> T0 >> L;
    
            double time = 0;
    
            while (true) {
                double dist = V * Tm;
    
                if (L <= dist) {
                    time += L / V;
                    break;
                } else {
                    L -= dist;
                    time += Tm;
                    if (L <= 1e-12) break;
                    time += T0;
                }
            }
    
            cout << time << "\n";
        }
    
        return 0;
    }
    
    • 0
      @ 2024-12-24 9:54:30

      C++ :

      #include <stdio.h>
      
      int main()
      {
        int casc;
        scanf("%d", &casc);
        for (int casi = 1; casi <= casc; casi++) {
          int v, t, t0, l;
          scanf("%d %d %d %d", &v, &t, &t0, &l);
          int s = v * t;
          double res = l / s * (t + t0);
          if (l % s == 0)
            res -= t0;
          else res += 1.0 * (l % s) / v;
          printf("%.3f\n", res);
        }
        return 0;
      }
      
      • 1

      信息

      ID
      1134
      时间
      1000ms
      内存
      128MiB
      难度
      10
      标签
      (无)
      递交数
      1
      已通过
      1
      上传者