QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501121 | #5151. Bottle Flip | xixu | WA | 0ms | 3872kb | C++20 | 1.0kb | 2024-08-02 14:31:02 | 2024-08-02 14:31:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int , int> PII;
const int N = 1e5 + 10;
int h , rr , da , dw;
long double an(long double x)
{
long double ans;
ans = ((dw - da) * x * x + da * h * h) / (2 * ((dw - da) * x + da * h));
return ans;
}
bool che(long double x)
{
long double lo = x - 1e-9;
if(an(lo) <= an(x)) return true;
return false;
}
void solve()
{
cin >> h >> rr >> da >> dw;
long double l = 0 , r = h;
// const double eps = 1e-6; // eps 表示精度,取决于题目对精度的要求
while (r - l > 1e-10)
{
long double mid = (l + r) / 2;
if(che(mid)) r = mid;
else l = mid;
}
cout << fixed << setprecision(12) << l << '\n';
}
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int t = 1;
// cin >> t;
while(t --)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
22 4 1 4
output:
7.333333326744
result:
ok found '7.3333333', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
7 2 655 988
output:
3.141594169989
result:
ok found '3.1415942', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 1 1 2
output:
0.414213562850
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3872kb
input:
1000 1000 999 1000
output:
499.844404861051
result:
wrong answer 1st numbers differ - expected: '499.8749375', found: '499.8444049', error = '0.0000611'