[CF77B] Falling Anvils - 概率

Description

给定 a,b,求 xx+sqrt(p)x+q 至少有一个实根的概率,p 属于 [0,a],q 属于 [-b,b],均为实数

Solution

算面积,分情况讨论即可

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main()
{
    ios::sync_with_stdio(false);

    int t;
    cin >> t;
    while (t--)
    {
        double a, b;
        cin >> a >> b;

        double ans = 0;
        if (b == 0)
            ans = 1;
        else if (4 * b < a)
            ans = 1 - b / a;
        else
            ans = 0.5 + a / b / 16;
        cout << fixed << setprecision(16) << ans << endl;
    }
}

相关文章:

  • 2021-09-29
  • 2021-06-23
  • 2021-10-29
  • 2021-06-21
  • 2022-12-23
  • 2021-12-09
  • 2022-02-05
猜你喜欢
  • 2022-01-20
  • 2022-12-23
  • 2021-11-29
  • 2021-06-14
  • 2021-05-12
  • 2022-02-06
  • 2021-08-29
相关资源
相似解决方案