QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#502603#5151. Bottle Flip1DemonS1WA 0ms3876kbC++20808b2024-08-03 10:17:522024-08-03 10:17:52

Judging History

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

  • [2024-08-03 10:17:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2024-08-03 10:17:52]
  • 提交

answer

#include<bits/stdc++.h>
//#define int long long
#define endl "\n"
#define ll long long
#define PII std::pair<int,int>
#define pi acos(-1)
using namespace std;
const int maxn = 1e4 + 5;
const double eps = 1e-10;
double r, h, da, dw;
double f(double hw) {
    double ha = h - hw;
    double mw = hw * dw;
    double ma = ha * da;
    double cw = hw / 2;
    double ca = h - ha / 2;
    return (ca * ma + cw * mw) / (ma + mw);
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);
    cin >> h >> r >> da >> dw;
    double l = 0, r = h;
    while (fabs(l - r) > eps) {
        double mid = (l + r) / 2;
        if (f(mid - eps) > f(mid + eps)) l = mid;
        else r = mid;
    }
    cout << l << endl;
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3876kb

input:

22 4 1 4

output:

7.333247005939

result:

wrong answer 1st numbers differ - expected: '7.3333333', found: '7.3332470', error = '0.0000118'