QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196890#5151. Bottle FlipRobeZH#AC ✓2ms4020kbC++14641b2023-10-02 02:48:302023-10-02 02:48:30

Judging History

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

  • [2023-10-02 02:48:30]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:4020kb
  • [2023-10-02 02:48:30]
  • 提交

answer

//
// Created by Nitit Jongsawatsataporn on 10/1/23.
//
#include<iostream>
using namespace std;

double h,r,a,w;

double cm(double wh) {
    double air_mass = (h-wh)*r*r*a;
    double wa_mass = wh*r*r*w;
    double cm = (air_mass * (wh + (h-wh)/2) + wa_mass * (wh/2))/(air_mass + wa_mass);
    return cm;
}

int main() {
    cin>>h>>r>>a>>w;
    double l,r,ll,rr;
    l = 0, r = h;
    for(int i=0;i<100000;i++) {
        ll = (2*l+r)/3;
        rr = (2*r+l)/3;
        if(cm(ll) > cm(rr)) {
            l = ll;
        }
        else {
            r = rr;
        }
    }
    printf("%.8f",l);
    return 0;
}

详细

Test #1:

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

input:

22 4 1 4

output:

7.33333334

result:

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

Test #2:

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

input:

7 2 655 988

output:

3.14159404

result:

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

Test #3:

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

input:

1 1 1 2

output:

0.41421356

result:

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

Test #4:

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

input:

1000 1000 999 1000

output:

499.87462654

result:

ok found '499.8746265', expected '499.8749375', error '0.0000006'

Test #5:

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

input:

1000 1000 1 1000

output:

30.65342991

result:

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

Test #6:

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

input:

1 1000 1 1000

output:

0.03065343

result:

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

Test #7:

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

input:

1000 1000 482 483

output:

499.74086032

result:

ok found '499.7408603', expected '499.7409326', error '0.0000001'

Test #8:

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

input:

1 1000 482 483

output:

0.49974097

result:

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

Test #9:

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

input:

1 1000 1 2

output:

0.41421355

result:

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

Test #10:

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

input:

1000 1000 1 2

output:

414.21355352

result:

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

Test #11:

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

input:

961 1000 979 983

output:

480.01001765

result:

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

Test #12:

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

input:

997 1000 977 983

output:

497.73697133

result:

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

Test #13:

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

input:

1 928 1 66

output:

0.10960059

result:

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

Test #14:

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

input:

1 928 2 88

output:

0.13100580

result:

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

Test #15:

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

input:

1 928 3 74

output:

0.16760091

result:

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

Test #16:

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

input:

1 928 3 41

output:

0.21290885

result:

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

Test #17:

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

input:

1 928 1 12

output:

0.22400923

result:

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

Test #18:

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

input:

2 928 89 93

output:

0.98900950

result:

ok found '0.9890095', expected '0.9890097', error '0.0000002'

Test #19:

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

input:

7 928 51 72

output:

3.19900985

result:

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

Test #20:

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

input:

722 547 709 752

output:

355.68636343

result:

ok found '355.6863634', expected '355.6863918', error '0.0000001'

Test #21:

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

input:

242 742 518 920

output:

103.74290328

result:

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

Test #22:

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

input:

873 701 43 201

output:

276.08755519

result:

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

Test #23:

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

input:

268 228 527 562

output:

131.84607782

result:

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

Test #24:

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

input:

312 558 341 839

output:

121.46838546

result:

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

Test #25:

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

input:

274 85 178 364

output:

112.75648861

result:

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

Test #26:

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

input:

641 539 341 977

output:

238.05443520

result:

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

Test #27:

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

input:

245 861 438 872

output:

101.61838327

result:

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

Test #28:

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

input:

640 181 156 606

output:

215.41983363

result:

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