QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501141 | #5151. Bottle Flip | 1DemonS1 | AC ✓ | 0ms | 4000kb | C++20 | 2.1kb | 2024-08-02 14:45:46 | 2024-08-02 14:45:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e4 + 9;
const int mod = 1e9 + 7;
const double eps = 1e-9;
#define inf 2e18
double h,r,da,dw;
double ans;
struct Node
{
double pos,val;
}a[N];
double cal(double x)
{
double res= (h * h * da + x * x *(dw - da)) / (h * da + x * (dw - da));
return res;
}
void solve()
{
cin>>h>>r>>da>>dw;
//ans = (h * h * da + h * h *(dw - da)) / (h * da + h * (dw - da));
double lpos=1,rpos=1000;
int pos;
double now=1,d=(rpos - lpos)/1000;
a[0]={0,1e16},a[1001]={1001,1e16};
for(int i=1;i<=1000;++i)
{
a[i]={now,cal(now)};
now += d;
}
for(int i=1;i<=1000;++i)
if(a[i].val<a[i-1].val && a[i].val < a[i + 1].val)
{
pos=i,lpos=a[i-1].pos,rpos=a[i+1].pos;
break;
}
now=lpos,d=(rpos - lpos)/1000;
for(int i=1;i<=1000;++i)
{
a[i]={now,cal(now)};
now += d;
}
for(int i=1;i<=1000;++i)
if(a[i].val<a[i-1].val && a[i].val < a[i + 1].val)
{
pos=i,lpos=a[i-1].pos,rpos=a[i+1].pos;
break;
}
now=lpos,d=(rpos - lpos)/1000;
for(int i=1;i<=1000;++i)
{
a[i]={now,cal(now)};
now += d;
}
for(int i=1;i<=1000;++i)
if(a[i].val<a[i-1].val && a[i].val < a[i + 1].val)
{
pos=i,lpos=a[i-1].pos,rpos=a[i+1].pos;
break;
}
now=lpos,d=(rpos - lpos)/1000;
for(int i=1;i<=1000;++i)
{
a[i]={now,cal(now)};
now += d;
}
for(int i=1;i<=1000;++i)
if(a[i].val<a[i-1].val && a[i].val < a[i + 1].val)
{
pos=i,lpos=a[i-1].pos,rpos=a[i+1].pos;
break;
}
// cout<< (a[pos].val)*1.00000000000/2.000000000000 <<'\n';
printf("%.10lf",a[pos].val*1.000000/2);
}
int main()
{
//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1; // cin>>_;
while (_--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
22 4 1 4
output:
7.3333333333
result:
ok found '7.3333333', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
7 2 655 988
output:
3.1415941720
result:
ok found '3.1415942', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
1 1 1 2
output:
0.4142135624
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
1000 1000 999 1000
output:
499.8749374609
result:
ok found '499.8749375', expected '499.8749375', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
1000 1000 1 1000
output:
30.6534300317
result:
ok found '30.6534300', expected '30.6534300', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
1 1000 1 1000
output:
0.0306534300
result:
ok found '0.0306534', expected '0.0306534', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
1000 1000 482 483
output:
499.7409325729
result:
ok found '499.7409326', expected '499.7409326', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 1000 482 483
output:
0.4997409326
result:
ok found '0.4997409', expected '0.4997409', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
1 1000 1 2
output:
0.4142135624
result:
ok found '0.4142136', expected '0.4142136', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1000 1000 1 2
output:
414.2135623731
result:
ok found '414.2135624', expected '414.2135624', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
961 1000 979 983
output:
480.0101931710
result:
ok found '480.0101932', expected '480.0101932', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3992kb
input:
997 1000 977 983
output:
497.7369880084
result:
ok found '497.7369880', expected '497.7369880', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1 928 1 66
output:
0.1096005908
result:
ok found '0.1096006', expected '0.1096006', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 928 2 88
output:
0.1310058042
result:
ok found '0.1310058', expected '0.1310058', error '0.0000000'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
1 928 3 74
output:
0.1676009074
result:
ok found '0.1676009', expected '0.1676009', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
1 928 3 41
output:
0.2129088554
result:
ok found '0.2129089', expected '0.2129089', error '0.0000000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
1 928 1 12
output:
0.2240092377
result:
ok found '0.2240092', expected '0.2240092', error '0.0000000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
2 928 89 93
output:
0.9890096617
result:
ok found '0.9890097', expected '0.9890097', error '0.0000000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
7 928 51 72
output:
3.1990098767
result:
ok found '3.1990099', expected '3.1990099', error '0.0000000'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3992kb
input:
722 547 709 752
output:
355.6863918193
result:
ok found '355.6863918', expected '355.6863918', error '0.0000000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
242 742 518 920
output:
103.7429034611
result:
ok found '103.7429035', expected '103.7429035', error '0.0000000'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
873 701 43 201
output:
276.0875558479
result:
ok found '276.0875558', expected '276.0875558', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
268 228 527 562
output:
131.8460919363
result:
ok found '131.8460919', expected '131.8460919', error '0.0000000'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
312 558 341 839
output:
121.4683850828
result:
ok found '121.4683851', expected '121.4683851', error '0.0000000'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
274 85 178 364
output:
112.7564906921
result:
ok found '112.7564907', expected '112.7564907', error '0.0000000'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
641 539 341 977
output:
238.0544387411
result:
ok found '238.0544387', expected '238.0544387', error '0.0000000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
245 861 438 872
output:
101.6183839219
result:
ok found '101.6183839', expected '101.6183839', error '0.0000000'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
640 181 156 606
output:
215.4198348909
result:
ok found '215.4198349', expected '215.4198349', error '0.0000000'