QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502602 | #5151. Bottle Flip | 1DemonS1 | WA | 0ms | 3872kb | C++20 | 807b | 2024-08-03 10:17:13 | 2024-08-03 10:17:13 |
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-8;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
input:
22 4 1 4
output:
7.333332450595
result:
ok found '7.3333325', expected '7.3333333', error '0.0000001'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
7 2 655 988
output:
3.141593620181
result:
ok found '3.1415936', expected '3.1415942', error '0.0000002'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
1 1 1 2
output:
0.414213553071
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
1000 1000 999 1000
output:
500.563576177228
result:
wrong answer 1st numbers differ - expected: '499.8749375', found: '500.5635762', error = '0.0013776'