QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#96250#5151. Bottle FlipSa3tElSefr#AC ✓2ms3740kbC++141.7kb2023-04-13 18:02:292023-04-13 18:02:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 18:02:32]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3740kb
  • [2023-04-13 18:02:29]
  • 提交

answer

///Etfsh5t nseet el rank
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x, y)
#define popCnt(x) (__builtin_popcountll(x))
// #define int ll

using ll = long long;
using ull = unsigned long long;
using uint = uint32_t;
using ii = pair<int, int>;

const int N = 3e5 + 5, A = 12, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const int INF = 1e18;
long double h, r, d_air, d_water;
long double calc(long double md)
{
    long double h_water = md;
    long double h_air = h - h_water;
    long double center_water = h_water / 2.0;
    long double center_air = h - h_air / 2.0;
    long double avg_center = (center_air * h_air * d_air + center_water * d_water * h_water) / (d_air * h_air + d_water * h_water);
    return avg_center;
}
void doWork()
{

    cin >> h >> r >> d_air >> d_water;
    long double lo = 0.0, hi = h;
    for (int k = 0; k < 300; k++)
    {
        long double md1 = lo + (hi - lo) / 3;
        long double md2 = hi - (hi - lo) / 3;
        if (calc(md1) < calc(md2))
            hi = md2;
        else
            lo = md1;
    }
    cout << fixed << setprecision(10) << lo << endl;
}
int32_t main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE
    int t = 1;
    // cin >> t;
    while (t--)
    {
        doWork();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3596kb

input:

22 4 1 4

output:

7.3333333316

result:

ok found '7.3333333', expected '7.3333333', error '0.0000000'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3680kb

input:

7 2 655 988

output:

3.1415941723

result:

ok found '3.1415942', expected '3.1415942', error '0.0000000'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

1 1 1 2

output:

0.4142135622

result:

ok found '0.4142136', expected '0.4142136', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

1000 1000 999 1000

output:

499.8749343542

result:

ok found '499.8749344', expected '499.8749375', error '0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3728kb

input:

1000 1000 1 1000

output:

30.6534300349

result:

ok found '30.6534300', expected '30.6534300', error '0.0000000'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

1 1000 1 1000

output:

0.0306534300

result:

ok found '0.0306534', expected '0.0306534', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

1000 1000 482 483

output:

499.7409366311

result:

ok found '499.7409366', expected '499.7409326', error '0.0000000'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

1 1000 482 483

output:

0.4997409356

result:

ok found '0.4997409', expected '0.4997409', error '0.0000000'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

1 1000 1 2

output:

0.4142135622

result:

ok found '0.4142136', expected '0.4142136', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

1000 1000 1 2

output:

414.2135626553

result:

ok found '414.2135627', expected '414.2135624', error '0.0000000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

961 1000 979 983

output:

480.0101938598

result:

ok found '480.0101939', expected '480.0101932', error '0.0000000'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

997 1000 977 983

output:

497.7369902431

result:

ok found '497.7369902', expected '497.7369880', error '0.0000000'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

1 928 1 66

output:

0.1096005908

result:

ok found '0.1096006', expected '0.1096006', error '0.0000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

1 928 2 88

output:

0.1310058042

result:

ok found '0.1310058', expected '0.1310058', error '0.0000000'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3704kb

input:

1 928 3 74

output:

0.1676009074

result:

ok found '0.1676009', expected '0.1676009', error '0.0000000'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1 928 3 41

output:

0.2129088555

result:

ok found '0.2129089', expected '0.2129089', error '0.0000000'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

1 928 1 12

output:

0.2240092378

result:

ok found '0.2240092', expected '0.2240092', error '0.0000000'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

2 928 89 93

output:

0.9890096618

result:

ok found '0.9890097', expected '0.9890097', error '0.0000000'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

7 928 51 72

output:

3.1990098788

result:

ok found '3.1990099', expected '3.1990099', error '0.0000000'

Test #20:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

722 547 709 752

output:

355.6863928926

result:

ok found '355.6863929', expected '355.6863918', error '0.0000000'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

242 742 518 920

output:

103.7429034818

result:

ok found '103.7429035', expected '103.7429035', error '0.0000000'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

873 701 43 201

output:

276.0875559306

result:

ok found '276.0875559', expected '276.0875558', error '0.0000000'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

268 228 527 562

output:

131.8460921006

result:

ok found '131.8460921', expected '131.8460919', error '0.0000000'

Test #24:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

312 558 341 839

output:

121.4683851022

result:

ok found '121.4683851', expected '121.4683851', error '0.0000000'

Test #25:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

274 85 178 364

output:

112.7564907387

result:

ok found '112.7564907', expected '112.7564907', error '0.0000000'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3680kb

input:

641 539 341 977

output:

238.0544388700

result:

ok found '238.0544389', expected '238.0544387', error '0.0000000'

Test #27:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

245 861 438 872

output:

101.6183839447

result:

ok found '101.6183839', expected '101.6183839', error '0.0000000'

Test #28:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

640 181 156 606

output:

215.4198349445

result:

ok found '215.4198349', expected '215.4198349', error '0.0000000'