QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501117#5151. Bottle FlipxixuWA 0ms3900kbC++201.0kb2024-08-02 14:28:272024-08-02 14:28:28

Judging History

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

  • [2024-08-02 14:28:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3900kb
  • [2024-08-02 14:28:27]
  • 提交

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 , r , 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 >> r >> 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;
}

详细

Test #1:

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

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: 3872kb

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: 3880kb

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: 3868kb

input:

1000 1000 999 1000

output:

499.876588110226

result:

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