QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140894 | #5151. Bottle Flip | emailam# | WA | 1ms | 3728kb | C++14 | 668b | 2023-08-16 22:35:18 | 2023-08-16 22:35:19 |
Judging History
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'