QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#616041 | #8022. Walker | gates_orz | WA | 19ms | 3924kb | C++20 | 2.1kb | 2024-10-05 21:41:18 | 2024-10-05 21:41:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
//#define double long double
#define int LL
double n, m;
const int N = 3e5 + 10;
const int M = N * 2;
const double eps=1e-8;
double p1,v1,p2,v2;
bool check(double x) {
double t1=p1/v1;
double t2=(n-p2)/v2;
t1=x-t1;
t2=x-t2;
if(t1>=eps&&t2>=eps) {
if(v1*t1+v2*t2>=(p2-p1)*2.0)return true;
}
t1=p1*2.0/v1;
t2=(n-p2)*2.0/v2;
t1=x-t1;
t2=x-t2;
if(t1>=eps&&t2>=eps) {
if(v1*t1+v2*t2>=p2-p1)return true;
}
double tmp,tot;
if(v1*x>=p1*2.0) {
tmp=v1*x-p1;
if(tmp>=n)return true;
tot=n-p2;
if(tmp<=p2) {
tot+=(p2-tmp)*2.0;
}
if(v2*x>=tot)return true;
}
/*if(v2*x>=(n-p2)*2.0) {
tmp=v2*x-(n-p2);
if(tmp>=n)return true;
tot=p1;
if(tmp>=p1) {
tot+=(tmp-p1)*2.0;
}
if(v1*x>=tot)return true;
}*/
return false;
}
void solve() {
cin>>n>>p1>>v1>>p2>>v2;
if(p1>=p2) {
swap(p1,p2);
swap(v1,v2);
}
double res=0;
double l=0,r=2e7;
//for(int i=1;i<=200;i++)
while(r-l>eps) {
double mid=(l+r)/2;
if(check(mid))r=mid,res=mid;
else l=mid;
}
//cerr<<"res="<<res<<endl;
//p1走全程
if((p1+n)/v1<=res) {
res=(p1+n)/v1;
}
if((n+n-p1)/v1<=res) {
res=(n+n-p1)/v1;
}
//p2走全程
if((n+n-p2)/v2<=res) {
res=(n+n-p2)/v2;
}
if((n+p2)/v2<=res) {
res=(n+p2)/v2;
}
/*if((p1/v1)*v2-(n-p2)>=(n-p1)) {
if(res>=(p1/v1))res=p1/v1;
}
if(((n-p2)/v2)*v1-p1>=p2) {
if(res>=(n-p2)/v2)res=(n-p2)/v2;
}*/
if(res>=max(p2/v2,(n-p1)/v1)) {
res=max(p2/v2,(n-p1)/v1);
}
cout<<fixed<<setprecision(10)<<res<<"\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--)solve();
return 0;
}
/*
1
2 1
a/b/c
a/b/d
e
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.0000000056 3827.8370013778
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.1000000000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.2000000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.1000000000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.3000000000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.2000000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.0000000000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.5000000058
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.5000000049
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.6000000076
result:
ok found '4.6000000', expected '4.6000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1 10.0 6.0 2.0 7.0 1.0
output:
3.6666666681
result:
ok found '3.6666667', expected '3.6666667', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
1 10.0 1.0 1.0 9.0 1.0
output:
6.0000000079
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1 10000.0 1.0 0.001 1.0 0.001
output:
9999000.0000000000
result:
ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
1 10.0 5.0 1.0 5.0 1.5
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #15:
score: -100
Wrong Answer
time: 19ms
memory: 3824kb
input:
10000 4306.063 4079.874 0.607 1033.423 0.847 8967.336 8026.500 0.398 283.019 0.876 9568.147 4481.616 0.405 800.114 0.684 9867.264 6184.040 0.312 9853.164 0.641 3344.364 730.612 0.539 1305.868 0.947 9336.180 3672.113 0.773 432.686 0.312 1468.243 59.762 0.840 1438.446 0.827 1355.133 1096.314 0.373 109...
output:
3827.8370013778 7999.3649921573 12559.3358024734 15371.5507020281 2637.6985195231 9931.0415175413 934.4943011413 2939.1796246649 5754.0328898753 2847.4271570023 10975.3236282195 2180.2786069652 23747.0454545455 6278.1035548731 872.3977055449 10734.3956442918 1005.0770288858 20225.1630901288 9878.009...
result:
wrong answer 25th numbers differ - expected: '20162.7111517', found: '21042.8924731', error = '0.0436539'