QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#502603 | #5151. Bottle Flip | 1DemonS1 | WA | 0ms | 3876kb | C++20 | 808b | 2024-08-03 10:17:52 | 2024-08-03 10:17:52 |
Judging History
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'