5 solutions

  • 0
    @ 2024-2-20 13:48:59

    初中几何题,延长梯形斜边相交于一点,2 次三角形相似 + 勾股定理

    注意除法和整型-浮点型相互转换

    #include <bits/stdc++.h>
    using namespace std;
    
    #define DBG(x) cout << #x << "=" << x << endl
    
    void solve() {
      double ans = 0.0;
      int r, a, b, h;
    
      cin >> r >> a >> b >> h;
    
      if (b >= 2 * r) {
        printf("Drop\n");
      } else {
        double t = (1.0 * b * h) / (a - b);
        double b1 = (1.0 * b) / 2;
        double v1 = pow(t, 2) + pow(b1, 2);
        ans = (1.0 * r * sqrt(v1)) / b1 - t;
        printf("Stuck\n%.10f\n", ans);
      }
    }
    
    int main() {
      solve();
    
      return 0;
    }
    

    Information

    ID
    127
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    4
    Tags
    # Submissions
    148
    Accepted
    67
    Uploaded By