QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501120#5151. Bottle FlipxixuWA 0ms3872kbC++201.0kb2024-08-02 14:30:052024-08-02 14:30:07

Judging History

你现在查看的是最新测评结果

  • [2024-08-02 14:30:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-08-02 14:30:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int , int> PII;


const int N = 1e5 + 10;

int h , rr , da , dw;

long double an(long double x)
{
    long double ans;
    ans = ((dw - da) * x * x + da * h * h) / (2 * ((dw - da) * x + da * h));
    return ans;
}

bool che(long double x)
{
    long double lo = x - 1e-9;
    if(an(lo) < an(x)) return true;
    return false;
}

void solve()
{
    cin >> h >> rr >> da >> dw;

    long double l = 0 , r = h;

        // const double eps = 1e-6;   // eps 表示精度,取决于题目对精度的要求
        while (r - l > 1e-10)
        {
            
            long double mid = (l + r) / 2;
            if(che(mid)) r = mid;
            else l = mid;
        }
        
        cout << fixed << setprecision(12) << l << '\n';





}



signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int t = 1;
    // cin >> t;
    while(t --)
    {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3872kb

input:

22 4 1 4

output:

7.333333331706

result:

ok found '7.3333333', expected '7.3333333', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

7 2 655 988

output:

3.141594174063

result:

ok found '3.1415942', expected '3.1415942', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1 1 1 2

output:

0.414213562908

result:

ok found '0.4142136', expected '0.4142136', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3776kb

input:

1000 1000 999 1000

output:

499.876588110226

result:

wrong answer 1st numbers differ - expected: '499.8749375', found: '499.8765881', error = '0.0000033'