QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502600 | #5151. Bottle Flip | 1DemonS1 | WA | 0ms | 3872kb | C++20 | 807b | 2024-08-03 10:16:15 | 2024-08-03 10:16:15 |
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-7;
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: 3820kb
input:
22 4 1 4
output:
7.333333224058
result:
ok found '7.3333332', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
7 2 655 988
output:
3.141594141722
result:
ok found '3.1415941', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
1 1 1 2
output:
0.414213538170
result:
ok found '0.4142135', expected '0.4142136', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3820kb
input:
1000 1000 999 1000
output:
499.500126810744
result:
wrong answer 1st numbers differ - expected: '499.8749375', found: '499.5001268', error = '0.0007498'