QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116756 | #5151. Bottle Flip | batrr# | AC ✓ | 1ms | 3772kb | C++23 | 1.5kb | 2023-06-30 01:44:46 | 2023-06-30 01:44:47 |
Judging History
answer
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const int N = 300500, inf = 1e9, mod = 998244353;
const ll INF = 1e18;
int sum(int a, int b) {
a += b;
if (a >= mod)
a -= mod;
return a;
}
int sub(int a, int b) {
a -= b;
if (a < 0)
a += mod;
return a;
}
int mult(int a, int b) {
return 1ll * a * b % mod;
}
int bp(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res = mult(res, a);
a = mult(a, a);
b >>= 1;
}
return res;
}
int inv(int x) {
return bp(x, mod - 2);
}
ll s;
typedef long double ld;
ld h, r, da, dw;
ld get(ld x) {
return ((dw * x * x + da * (h * h - x * x))) / (dw * x + da * (h - x));
}
void solve() {
cin >> h >> r >> da >> dw;
ld L = 0;
ld R = h;
for (int iter = 0; iter < 120; iter++) {
ld f1 = (2 * L + R) / 3;
ld f2 = (2 * R + L) / 3;
if (get(f1) > get(f2)) L = f1;
else R = f2;
}
cout << fixed << setprecision(12) << (L + R) / 2 << '\n';
}
int main() {
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << endl;
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3720kb
input:
22 4 1 4
output:
7.333333330272
result:
ok found '7.3333333', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
7 2 655 988
output:
3.141594169741
result:
ok found '3.1415942', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
1 1 1 2
output:
0.414213562141
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
1000 1000 999 1000
output:
499.874932312411
result:
ok found '499.8749323', expected '499.8749375', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
1000 1000 1 1000
output:
30.653430026962
result:
ok found '30.6534300', expected '30.6534300', error '0.0000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
1 1000 1 1000
output:
0.030653430021
result:
ok found '0.0306534', expected '0.0306534', error '0.0000000'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
1000 1000 482 483
output:
499.740932833276
result:
ok found '499.7409328', expected '499.7409326', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
1 1000 482 483
output:
0.499740933051
result:
ok found '0.4997409', expected '0.4997409', error '0.0000000'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
1 1000 1 2
output:
0.414213562141
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
1000 1000 1 2
output:
414.213562265415
result:
ok found '414.2135623', expected '414.2135624', error '0.0000000'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
961 1000 979 983
output:
480.010191955121
result:
ok found '480.0101920', expected '480.0101932', error '0.0000000'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
997 1000 977 983
output:
497.736985331894
result:
ok found '497.7369853', expected '497.7369880', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
1 928 1 66
output:
0.109600590823
result:
ok found '0.1096006', expected '0.1096006', error '0.0000000'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
1 928 2 88
output:
0.131005804162
result:
ok found '0.1310058', expected '0.1310058', error '0.0000000'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
1 928 3 74
output:
0.167600907394
result:
ok found '0.1676009', expected '0.1676009', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
1 928 3 41
output:
0.212908855428
result:
ok found '0.2129089', expected '0.2129089', error '0.0000000'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
1 928 1 12
output:
0.224009237749
result:
ok found '0.2240092', expected '0.2240092', error '0.0000000'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
2 928 89 93
output:
0.989009661039
result:
ok found '0.9890097', expected '0.9890097', error '0.0000000'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
7 928 51 72
output:
3.199009875599
result:
ok found '3.1990099', expected '3.1990099', error '0.0000000'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
722 547 709 752
output:
355.686391182868
result:
ok found '355.6863912', expected '355.6863918', error '0.0000000'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
242 742 518 920
output:
103.742903429113
result:
ok found '103.7429034', expected '103.7429035', error '0.0000000'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
873 701 43 201
output:
276.087555750567
result:
ok found '276.0875558', expected '276.0875558', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
268 228 527 562
output:
131.846091808243
result:
ok found '131.8460918', expected '131.8460919', error '0.0000000'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
312 558 341 839
output:
121.468385010967
result:
ok found '121.4683850', expected '121.4683851', error '0.0000000'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
274 85 178 364
output:
112.756490692998
result:
ok found '112.7564907', expected '112.7564907', error '0.0000000'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
641 539 341 977
output:
238.054438755370
result:
ok found '238.0544388', expected '238.0544387', error '0.0000000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
245 861 438 872
output:
101.618383851431
result:
ok found '101.6183839', expected '101.6183839', error '0.0000000'
Test #28:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
640 181 156 606
output:
215.419834837671
result:
ok found '215.4198348', expected '215.4198349', error '0.0000000'