QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502776 | #5151. Bottle Flip | Umok | AC ✓ | 0ms | 3972kb | C++20 | 932b | 2024-08-03 13:47:54 | 2024-08-03 13:48:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e4 + 5;
#define int long long
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX
#define mod 10007
#define eps 1e-7
double h, rr, p1, p2;
double calc(double l)
{
// double ha = h - l;
// double mw = l * p2;
// double ma = ha * p1;
// double cw = l / 2;
// double ca = h - ha / 2;
// return (ca * ma + cw * mw);
return (l * l * p1 + (h - l) * p2 * (h - l)) / 2 / (l * p1 + (h - l) * p2);
}
signed main()
{
cin >> h >> rr >> p1 >> p2;
double l = 0, r = h;
while (r - l > eps)
{
double mid1 = (l + r) / 2;
double mid2 = (r + mid1) / 2;
double x = calc(mid1);
double y = calc(mid2);
if (x > y)
l = mid1;
else
r = mid2;
}
cout << printf("%.10lf", h - l) << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
22 4 1 4
output:
7.333333397512
result:
ok found '7.3333334', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
7 2 655 988
output:
3.141594257612
result:
ok found '3.1415943', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
1 1 1 2
output:
0.414213598912
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
1000 1000 999 1000
output:
499.874939334914
result:
ok found '499.8749393', expected '499.8749375', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1000 1000 1 1000
output:
30.653430226613
result:
ok found '30.6534302', expected '30.6534300', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
1 1000 1 1000
output:
0.030653458212
result:
ok found '0.0306535', expected '0.0306534', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
1000 1000 482 483
output:
499.740937229914
result:
ok found '499.7409372', expected '499.7409326', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
1 1000 482 483
output:
0.499740975712
result:
ok found '0.4997410', expected '0.4997409', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
1 1000 1 2
output:
0.414213598912
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
1000 1000 1 2
output:
414.213560884614
result:
ok found '414.2135609', expected '414.2135624', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
961 1000 979 983
output:
480.010193987914
result:
ok found '480.0101940', expected '480.0101932', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
997 1000 977 983
output:
497.736994653114
result:
ok found '497.7369947', expected '497.7369880', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
1 928 1 66
output:
0.109600636112
result:
ok found '0.1096006', expected '0.1096006', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
1 928 2 88
output:
0.131005845212
result:
ok found '0.1310058', expected '0.1310058', error '0.0000000'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
1 928 3 74
output:
0.167600969212
result:
ok found '0.1676010', expected '0.1676009', error '0.0000001'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
1 928 3 41
output:
0.212908902812
result:
ok found '0.2129089', expected '0.2129089', error '0.0000000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
1 928 1 12
output:
0.224009272212
result:
ok found '0.2240093', expected '0.2240092', error '0.0000000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
2 928 89 93
output:
0.989009696512
result:
ok found '0.9890097', expected '0.9890097', error '0.0000000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
7 928 51 72
output:
3.199009943712
result:
ok found '3.1990099', expected '3.1990099', error '0.0000000'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
722 547 709 752
output:
355.686394430314
result:
ok found '355.6863944', expected '355.6863918', error '0.0000000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
242 742 518 920
output:
103.742904367514
result:
ok found '103.7429044', expected '103.7429035', error '0.0000000'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
873 701 43 201
output:
276.087556578414
result:
ok found '276.0875566', expected '276.0875558', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
268 228 527 562
output:
131.846093721114
result:
ok found '131.8460937', expected '131.8460919', error '0.0000000'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
312 558 341 839
output:
121.468386479914
result:
ok found '121.4683865', expected '121.4683851', error '0.0000000'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
274 85 178 364
output:
112.756491637614
result:
ok found '112.7564916', expected '112.7564907', error '0.0000000'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
641 539 341 977
output:
238.054440236614
result:
ok found '238.0544402', expected '238.0544387', error '0.0000000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
245 861 438 872
output:
101.618384861414
result:
ok found '101.6183849', expected '101.6183839', error '0.0000000'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
640 181 156 606
output:
215.419839119414
result:
ok found '215.4198391', expected '215.4198349', error '0.0000000'