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
| #define MAX 10 double dp[MAX][2]; int n; double S, T; double sx[100], sy[100], tx[100], ty[100]; double dis(double x, double y, double xx, double yy) { return sqrt((x - xx) * (x - xx) + (y - yy) * (y - yy)); } signed main() { IOS; cin >> n >> S >> T; for (int i = 1; i <= n; i++) { cin >> sx[i] >> sy[i] >> tx[i] >> ty[i]; } double ans = 1111111111.0; vector<int> v(n); for (int i = 0; i < n; i++) { v[i] = i + 1; } do { double dp[15][2] = {0.0}; for (int op = 0; op < n; op++) { int i = v[op]; int j = op ? v[op - 1] : 0; double len = dis(sx[i], sy[i], tx[i], ty[i]) / T; dp[i][0] = min(dp[j][0] + dis(sx[j], sy[j], tx[i], ty[i]) / S, dp[j][1] + dis(tx[j], ty[j], tx[i], ty[i]) / S) + len; dp[i][1] = min(dp[j][0] + dis(sx[j], sy[j], sx[i], sy[i]) / S, dp[j][1] + dis(tx[j], ty[j], sx[i], sy[i]) / S) + len; } ans = min(ans, (double)min(dp[v[n - 1]][0], dp[v[n - 1]][1])); } while (next_permutation(v.begin(), v.end())); cout << fixed << setprecision(20) << ans << endl; return 0; }
|