QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140894#5151. Bottle Flipemailam#WA 1ms3728kbC++14668b2023-08-16 22:35:182023-08-16 22:35:19

Judging History

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

  • [2023-08-16 22:35:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2023-08-16 22:35:18]
  • 提交

answer

# include <bits/stdc++.h>

using namespace std ;

const double PI = acos(-1) ;

int main(){
    int h , r , da , dw ; cin >> h >> r >> da >> dw ;
    double s = 0 , e = h ;
    auto f = [&]( double mid ){
        double w = PI * mid * r * r * dw ;
        double a = PI * ( h - mid ) * r * r * da ;
        return ( w * h/2 + a * ( mid + (h - mid)/2 )  )/( w + a ) ;
    };
    for (int i = 0; i < 100; ++i) {
        double m1 = s + (e-s)/3 ;
        double m2 = e - (e-s)/3 ;
        if ( f(m1) <= f(m2) ){
            s = m1 ;
        }else{
            e = m2 ;
        }
    }
    cout << fixed << setprecision(10) << s ;
    return 0 ;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3704kb

input:

22 4 1 4

output:

7.3333333263

result:

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

Test #2:

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

input:

7 2 655 988

output:

3.1415942445

result:

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

Test #3:

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

input:

1 1 1 2

output:

0.4142135695

result:

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

Test #4:

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

input:

1000 1000 999 1000

output:

499.8749450568

result:

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

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3728kb

input:

1000 1000 1 1000

output:

30.6534664883

result:

wrong answer 1st numbers differ - expected: '30.6534300', found: '30.6534665', error = '0.0000012'