QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65968#5151. Bottle Fliptriple__a#AC ✓5ms3596kbC++17566b2022-12-04 19:35:352022-12-04 19:35:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-04 19:35:39]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:3596kb
  • [2022-12-04 19:35:35]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N=100007;
const double EPS=1e-9;
int h,r,da,dw;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout.precision(15);
    cin>>h>>r>>da>>dw;
    double L=0, R=h;
    auto solve=[&](double now){
        double m1=dw*now, m2=da*(h-now);
        return now*m1/(m1+m2)+(now+h)*m2/(m1+m2);
    };
    while (R-L>EPS){
        double m1=L+(R-L)/3, m2=R-(R-L)/3;
        if (solve(m1)>solve(m2)) L=m1;
        else R=m2;
    }
    cout<<L;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 3464kb

input:

22 4 1 4

output:

7.33333323292446

result:

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

Test #2:

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

input:

7 2 655 988

output:

3.14159409428136

result:

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

Test #3:

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

input:

1 1 1 2

output:

0.414213558670766

result:

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

Test #4:

score: 0
Accepted
time: 4ms
memory: 3480kb

input:

1000 1000 999 1000

output:

499.8747864967

result:

ok found '499.8747865', expected '499.8749375', error '0.0000003'

Test #5:

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

input:

1000 1000 1 1000

output:

30.6534299825993

result:

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

Test #6:

score: 0
Accepted
time: 4ms
memory: 3504kb

input:

1 1000 1 1000

output:

0.0306534296650255

result:

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

Test #7:

score: 0
Accepted
time: 3ms
memory: 3580kb

input:

1000 1000 482 483

output:

499.740948693324

result:

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

Test #8:

score: 0
Accepted
time: 3ms
memory: 3504kb

input:

1 1000 482 483

output:

0.499740749201366

result:

ok found '0.4997407', expected '0.4997409', error '0.0000002'

Test #9:

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

input:

1 1000 1 2

output:

0.414213558670766

result:

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

Test #10:

score: 0
Accepted
time: 4ms
memory: 3472kb

input:

1000 1000 1 2

output:

414.213567032526

result:

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

Test #11:

score: 0
Accepted
time: 3ms
memory: 3412kb

input:

961 1000 979 983

output:

480.010004441538

result:

ok found '480.0100044', expected '480.0101932', error '0.0000004'

Test #12:

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

input:

997 1000 977 983

output:

497.736981709349

result:

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

Test #13:

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

input:

1 928 1 66

output:

0.109600589965807

result:

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

Test #14:

score: 0
Accepted
time: 5ms
memory: 3532kb

input:

1 928 2 88

output:

0.13100579985205

result:

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

Test #15:

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

input:

1 928 3 74

output:

0.167600905703631

result:

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

Test #16:

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

input:

1 928 3 41

output:

0.2129088544202

result:

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

Test #17:

score: 0
Accepted
time: 3ms
memory: 3584kb

input:

1 928 1 12

output:

0.224009239004964

result:

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

Test #18:

score: 0
Accepted
time: 3ms
memory: 3520kb

input:

2 928 89 93

output:

0.989009655612482

result:

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

Test #19:

score: 0
Accepted
time: 4ms
memory: 3384kb

input:

7 928 51 72

output:

3.19900984302137

result:

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

Test #20:

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

input:

722 547 709 752

output:

355.68638359924

result:

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

Test #21:

score: 0
Accepted
time: 4ms
memory: 3468kb

input:

242 742 518 920

output:

103.742901308251

result:

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

Test #22:

score: 0
Accepted
time: 4ms
memory: 3476kb

input:

873 701 43 201

output:

276.087549375751

result:

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

Test #23:

score: 0
Accepted
time: 3ms
memory: 3472kb

input:

268 228 527 562

output:

131.846082732593

result:

ok found '131.8460827', expected '131.8460919', error '0.0000001'

Test #24:

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

input:

312 558 341 839

output:

121.468386969024

result:

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

Test #25:

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

input:

274 85 178 364

output:

112.756490420516

result:

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

Test #26:

score: 0
Accepted
time: 3ms
memory: 3404kb

input:

641 539 341 977

output:

238.054435895601

result:

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

Test #27:

score: 0
Accepted
time: 4ms
memory: 3520kb

input:

245 861 438 872

output:

101.618381966627

result:

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

Test #28:

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

input:

640 181 156 606

output:

215.419832579171

result:

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