QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#96491 | #5151. Bottle Flip | RoomGamadan# | AC ✓ | 2ms | 3792kb | C++20 | 1.3kb | 2023-04-13 22:19:31 | 2023-04-13 22:19:56 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
#define F first
#define S second
typedef long long ll;
typedef long double ld;
bool multipleTestCases = 0, sublime = 0;
const int N = 4e5 + 5, INF = 1e9 + 5, mod = 1e9 + 7, LOG = 22, SQ = 500;
const ld pi = acos(-1), EPS = 1e-9;
ld h, r, da, dw;
ld calc(ld x) {
ld mw = dw * (pi * r * r * x);
ld ma = da * (pi * r * r * (h - x));
return (mw * x + ma * (h - x)) / (mw + ma);
}
void doWork() {
cin >> h >> r >> da >> dw;
ld s = 0, e = h, m1, m2;
for (int i = 0; i < 300; i++) {
m1 = s + (e - s) / 3;
m2 = e - (e - s) / 3;
if (calc(m1) < calc(m2)) {
e = m2;
}
else {
s = m1;
}
}
cout << fixed << setprecision(12) << (s + e) / 2;
}
signed main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
#ifndef ONLINE_JUDGE
if (sublime) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
#endif
int tests = 1;
if (multipleTestCases) {
cin >> tests;
}
for (int tc = 1; tc <= tests; tc++) {
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3764kb
input:
22 4 1 4
output:
7.333333334589
result:
ok found '7.3333333', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3624kb
input:
7 2 655 988
output:
3.141594172287
result:
ok found '3.1415942', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
1 1 1 2
output:
0.414213562405
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1000 1000 999 1000
output:
499.874937475161
result:
ok found '499.8749375', expected '499.8749375', error '0.0000000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
1000 1000 1 1000
output:
30.653430034879
result:
ok found '30.6534300', expected '30.6534300', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
1 1000 1 1000
output:
0.030653430039
result:
ok found '0.0306534', expected '0.0306534', error '0.0000000'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
1000 1000 482 483
output:
499.740932602902
result:
ok found '499.7409326', expected '499.7409326', error '0.0000000'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
1 1000 482 483
output:
0.499740932682
result:
ok found '0.4997409', expected '0.4997409', error '0.0000000'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
1 1000 1 2
output:
0.414213562434
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3628kb
input:
1000 1000 1 2
output:
414.213562446840
result:
ok found '414.2135624', expected '414.2135624', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
961 1000 979 983
output:
480.010193296662
result:
ok found '480.0101933', expected '480.0101932', error '0.0000000'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3720kb
input:
997 1000 977 983
output:
497.736988043338
result:
ok found '497.7369880', expected '497.7369880', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
1 928 1 66
output:
0.109600590907
result:
ok found '0.1096006', expected '0.1096006', error '0.0000000'
Test #14:
score: 0
Accepted
time: 2ms
memory: 3644kb
input:
1 928 2 88
output:
0.131005804221
result:
ok found '0.1310058', expected '0.1310058', error '0.0000000'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
1 928 3 74
output:
0.167600907443
result:
ok found '0.1676009', expected '0.1676009', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
1 928 3 41
output:
0.212908855509
result:
ok found '0.2129089', expected '0.2129089', error '0.0000000'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3720kb
input:
1 928 1 12
output:
0.224009237833
result:
ok found '0.2240092', expected '0.2240092', error '0.0000000'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
2 928 89 93
output:
0.989009661741
result:
ok found '0.9890097', expected '0.9890097', error '0.0000000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
7 928 51 72
output:
3.199009876663
result:
ok found '3.1990099', expected '3.1990099', error '0.0000000'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
722 547 709 752
output:
355.686391822953
result:
ok found '355.6863918', expected '355.6863918', error '0.0000000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
242 742 518 920
output:
103.742903474556
result:
ok found '103.7429035', expected '103.7429035', error '0.0000000'
Test #22:
score: 0
Accepted
time: 2ms
memory: 3792kb
input:
873 701 43 201
output:
276.087555918879
result:
ok found '276.0875559', expected '276.0875558', error '0.0000000'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
268 228 527 562
output:
131.846091959914
result:
ok found '131.8460920', expected '131.8460919', error '0.0000000'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3708kb
input:
312 558 341 839
output:
121.468385108886
result:
ok found '121.4683851', expected '121.4683851', error '0.0000000'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3760kb
input:
274 85 178 364
output:
112.756490716249
result:
ok found '112.7564907', expected '112.7564907', error '0.0000000'
Test #26:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
641 539 341 977
output:
238.054438769723
result:
ok found '238.0544388', expected '238.0544387', error '0.0000000'
Test #27:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
245 861 438 872
output:
101.618383937444
result:
ok found '101.6183839', expected '101.6183839', error '0.0000000'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
640 181 156 606
output:
215.419834949269
result:
ok found '215.4198349', expected '215.4198349', error '0.0000000'