#include <iostream>
#include <iomanip>
using namespace std;
void solve()
{
long double ans;
long double t1, t2, t3;
int L, v0, v1, v2, v3, pos0, pos1=-1, pos2=-1, pos3=-1;
string a1, a2, a3;
cin >> L >> v0 >> v1 >> v2 >> v3;
cin >> a1 >> a2 >> a3;
for(int i = 1; i < L; i++)
if(a3[i] == '#')
pos3 = i;
for(int i = 0; i < L; i++)
if(a2[i] == '#')
pos2 = i;
for(int i = 0; i < L; i++)
if(a1[i] == '#')
pos1 = i;
if(pos3 == -1)
t3 = 0;
else
t3 = (long double)(pos3 + 1) / (v0 - v3);
if(pos2 == -1)
t2 = 0;
else
t2 = (long double)(pos2 + 1) / (v0 - v2);
if(pos1 == -1)
t1 = 0;
else
t1 = (long double)(pos1 + 1) / (v0 - v1);
ans = max(max(t1,t2),t3);
cout << ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout << setprecision(12) << fixed;
solve();
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <iostream> #include <iomanip> using namespace std; void solve() { long double ans; long double t1, t2, t3; int L, v0, v1, v2, v3, pos0, pos1=-1, pos2=-1, pos3=-1; string a1, a2, a3; cin >> L >> v0 >> v1 >> v2 >> v3; cin >> a1 >> a2 >> a3; for(int i = 1; i < L; i++) if(a3[i] == '#') pos3 = i; for(int i = 0; i < L; i++) if(a2[i] == '#') pos2 = i; for(int i = 0; i < L; i++) if(a1[i] == '#') pos1 = i; if(pos3 == -1) t3 = 0; else t3 = (long double)(pos3 + 1) / (v0 - v3); if(pos2 == -1) t2 = 0; else t2 = (long double)(pos2 + 1) / (v0 - v2); if(pos1 == -1) t1 = 0; else t1 = (long double)(pos1 + 1) / (v0 - v1); ans = max(max(t1,t2),t3); cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(12) << fixed; solve(); return 0; } |
English