QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501270 | #5151. Bottle Flip | ssmy | WA | 0ms | 3828kb | C++20 | 744b | 2024-08-02 16:13:57 | 2024-08-02 16:13:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
double heart(double h, double x, double pw, double pa)
{
return 0.5 * (pw * x * x + pa * (h - x) * (h - x)) / (pw * x + pa * (h - x));
}
double search(double h, double pw, double pa)
{
double head = 0;
double tail = h;
while ((tail - head) > 1e-6)
{
double mid = (head + tail) / 2.0;
if (heart(h, mid, pw, pa) < heart(h, mid + 1e-6, pw, pa))
{
tail = mid;
}
else
{
head = mid;
}
}
return head;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
double h, pw, pa, r;
cin >> h >> r >> pa >> pw;
cout << fixed << setprecision(10) << search(h, pw, pa);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
22 4 1 4
output:
7.3333322406
result:
ok found '7.3333322', expected '7.3333333', error '0.0000001'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
7 2 655 988
output:
3.1415930986
result:
ok found '3.1415931', expected '3.1415942', error '0.0000003'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3824kb
input:
1 1 1 2
output:
0.4142122269
result:
wrong answer 1st numbers differ - expected: '0.4142136', found: '0.4142122', error = '0.0000013'