QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#630244 | #8022. Walker | Mcggvc | WA | 1ms | 4020kb | C++17 | 2.1kb | 2024-10-11 17:18:55 | 2024-10-11 17:18:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define double long double
double cnm(double n, double p1, double p2, double v1, double v2) {
double ans = n / v1;
ans = min(ans, ((n - p2) + n) / v2);
ans = min(ans, max(p2 / v1 , (n - p2) / v2));
double tmpx = (p2 / v1 - (n - p2) / v2) / (1.0 / v1 + 2.0 / v2);
if(tmpx > 0 && tmpx < p2) ans = min(ans, (p2 - tmpx) / v1);
ans=min(ans,(n-p2+n)/(v1+v2));
ans=min(ans,max(p2/v1,(n-p2)/v2));
return ans;
}
double nmsl(double l1, double l2, double l3, double l, double v1, double v2) {
double ans = max((2.0 * l2 + l1) / v1, l3 / v2);
// ans = min(ans, )
double tmpx = (2.0 * l3 + l2) / v2 - l1 / v1;
tmpx /= (2.0 / v1 + 1.0 / v2);
if(tmpx > 0 && tmpx < l2) ans = min(ans, (2.0 * tmpx + l1) / v1);
return ans;
}
double n, p1, p2, v1, v2;
double ans;
inline void Min(double tmp) {
ans = min(ans, tmp);
}
void solve(){
cin >> n >> p1 >> v1 >> p2 >> v2;
if(p1 > p2) {
swap(p1, p2); swap(v1, v2);
}
if(p1 == 0 && p2 == n) {
printf("%.10Lf\n",n / (v1 + v2));
return ;
} else if(p1 == 0) {
printf("%.10Lf\n",cnm(n, p1, p2, v1, v2));
return ;
} else if(p2 == n) {
printf("%.10Lf\n", cnm(n, 0, n - p1, v2, v1));
return ;
}
//<-- -->
double l1 = p1, l2 = p2 - p1, l3 = n - p2, l = n;
// ans = 1e9;
ans = (l + l3) / v2;
Min((l + l1) / v1);
Min((l1 + l3 + l) / (v1 + v2)); //
Min(max((l1 * 2 + l2) / v1, l3 / v2));
Min(max((l3 * 2 + l2) / v2, l1 / v1));
//---> <---
Min(max((l2 + l3) / v1, (l1 + l2) / v2));
double tmpx = (2.0 * l2 + l3) / v2 - l1 / v1;
tmpx /= (2.0 / v1 + 2.0 / v2);
if(tmpx > 0 && tmpx < l2) Min((2.0 * tmpx + l1) / v1);
// ---> --->
Min(nmsl(l1, l2, l3, l, v1, v2));
Min(nmsl(l3, l2, l1, l, v2, v1));
printf("%.10Lf\n", ans);
}
signed main(){
// freopen("data.in", "r", stdin);
ios::sync_with_stdio(false);
int T; cin >> T;
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4020kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.0000000000 3827.8370013755
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3856kb
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: -100
Wrong Answer
time: 0ms
memory: 3980kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.8000000000
result:
wrong answer 1st numbers differ - expected: '1.2000000', found: '1.8000000', error = '0.5000000'