QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226856#5151. Bottle FlipFyind#AC ✓1ms3924kbC++141.2kb2023-10-26 17:20:132023-10-26 17:20:13

Judging History

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

  • [2023-10-26 17:20:13]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3924kb
  • [2023-10-26 17:20:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 6000105;
const int maxm = 6000005;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int inf = 0X3f3f3f3f;
#define debug(x) cout<<#x<<':'<<x<<endl;

typedef long double ld;

const ld pi=acos(-1.0);

//const int maxn=1e5+100;
const ld eps=1e-9;
ld h,r,da,dw;

ld check(ld a){
    
    // double ans1=0.5*mid*(1-da/dw)+0.5*h*(da/dw);
    // double ans2=0.5*h-mid/2*(dw/da-1);
    // if(ans1<=mid) return ans1;
    // else if(ans2>=mid) return ans2;
    // else {
    //     cout<<"****"<<endl;
    //     return 0;
    // }
    

    // ld ans=0.5*h*(mid+h)*da/(mid*dw+mid*3*da+h*da);
    // //ld ans2=
    // ans=ans*h/2+mid/2;
    // ld ans2=(a+(h-a)/2)*da*h/2;
    // ld ansx=a/2*dw+(a+(h-a)/2)*da;
    // ld anss=ans2/ansx+a/2;

    ld anss=(h-a)*da/(a*dw+(h-a)*da)*h/2+a/2;
    return anss;

    
}
int main(){
    
    cin>>h>>r>>da>>dw;

    ld l=0,r=h;
    while(r-l>eps){
        ld mid1=(2*l+r)/3;
        ld mid2=(l+2*r)/3;

        if(check(mid1)<check(mid2)){
            r=mid2;
        }
        else {
            l=mid1;
        }
    }

    cout<<fixed<<setprecision(8)<<l<<endl;
    //cout<<l<<endl;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3908kb

input:

22 4 1 4

output:

7.33333333

result:

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

Test #2:

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

input:

7 2 655 988

output:

3.14159417

result:

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

Test #3:

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

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: 0ms
memory: 3752kb

input:

1000 1000 999 1000

output:

499.87493794

result:

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

Test #5:

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

input:

1000 1000 1 1000

output:

30.65343003

result:

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

Test #6:

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

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: 0ms
memory: 3808kb

input:

1000 1000 482 483

output:

499.74093574

result:

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

Test #8:

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

input:

1 1000 482 483

output:

0.49974094

result:

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

Test #9:

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

input:

1 1000 1 2

output:

0.41421356

result:

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

Test #10:

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

input:

1000 1000 1 2

output:

414.21356250

result:

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

Test #11:

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

input:

961 1000 979 983

output:

480.01019687

result:

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

Test #12:

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

input:

997 1000 977 983

output:

497.73698698

result:

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

Test #13:

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

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: 0ms
memory: 3668kb

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: 0ms
memory: 3856kb

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: 0ms
memory: 3848kb

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: 0ms
memory: 3852kb

input:

1 928 1 12

output:

0.22400924

result:

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

Test #18:

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

input:

2 928 89 93

output:

0.98900966

result:

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

Test #19:

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

input:

7 928 51 72

output:

3.19900988

result:

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

Test #20:

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

input:

722 547 709 752

output:

355.68639182

result:

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

Test #21:

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

input:

242 742 518 920

output:

103.74290352

result:

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

Test #22:

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

input:

873 701 43 201

output:

276.08755589

result:

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

Test #23:

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

input:

268 228 527 562

output:

131.84609216

result:

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

Test #24:

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

input:

312 558 341 839

output:

121.46838513

result:

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

Test #25:

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

input:

274 85 178 364

output:

112.75649070

result:

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

Test #26:

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

input:

641 539 341 977

output:

238.05443884

result:

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

Test #27:

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

input:

245 861 438 872

output:

101.61838397

result:

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

Test #28:

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

input:

640 181 156 606

output:

215.41983498

result:

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