QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#644566 | #8022. Walker | ATM12345# | WA | 0ms | 3996kb | C++17 | 1.0kb | 2024-10-16 14:38:03 | 2024-10-16 14:38:04 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define Ma 1000005
#define mod 998244353
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld long double
#define eps 1e-12
using namespace std;
ld n,p1,v1,p2,v2;
ll sgn(ld x)
{
if (fabs(x)<eps)
return 0;
if (x<0)
return -1;
return 1;
}
ld gw(ld r,ld x,ld v)
{
if (sgn(x-r)>=0)
return x/v;
return (min(x/v,(r-x)/v)+r/v);
}
void sol()
{
cin>>n>>p1>>v1>>p2>>v2;
ld ans=min(gw(n,p1,v1),gw(n,p2,v2));
//printf("ans=%.6Lf\n",ans);
ld l=0,r=n,cnt=0;
while (sgn(r-l)>=0&&cnt<=150)
{
cnt++;
ld mid1=l+(r-l)/3,mid2=mid1+(r-mid1)/2;
ld val1=min(max(gw(mid1,p1,v1),gw(n-mid1,n-p2,v2)),max(gw(n-mid1,n-p1,v1),gw(mid1,p2,v2)));
ld val2=min(max(gw(mid2,p1,v1),gw(n-mid2,n-p2,v2)),max(gw(n-mid2,n-p1,v1),gw(mid2,p2,v2)));
ans=min({ans,val1,val2});
if (val1>val2)
l=mid1;
else
r=mid2;
}
printf("%.6Lf\n",ans);
}
int main()
{
IOS
ll tt=1;
cin>>tt;
while (tt--)
sol();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3996kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.000000 3827.837001
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.100000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.200000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.100000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.300000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.200000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.000000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3980kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
60.000000
result:
wrong answer 1st numbers differ - expected: '57.5000000', found: '60.0000000', error = '0.0434783'