Link: https://ac.nowcoder.com/acm/contest/5086/B
Source: Niuke.com
space restrictions: C / C ++ 32768K, other languages 65536k
64bit the IO the Format: LLD%
Title description
The way they train is: n people run in a row, the distance between them is u meters, and each person's normal speed is v meters / second.
When a delivery person is at the end, he needs to run forward at his highest speed at that time until he exceeds the head of the person u meters, and then returns to the original speed v meters / second.
The n individuals are initially arranged in a random order, and the probability of each order is completely equal. What is the expected time to complete a round (each person chases the first row, and the sequence is restored)?
Enter description:
Integer n in the first line (<= 1000), real number v (<= 100), real number u (<= 10)
The speed of each person in the second line n real numbers c [i] (<= 50000)
The third line of n real values each person attenuation d [i] (<= 10)
Enter the data to ensure that everyone's speed will not decay to <= v
Output description:
The answer retains 3 decimal places.
Input
10 37.618 0.422 72.865 126.767 202.680 106.102 99.516 134.418 167.952 173.646 120.210 136.571 2.941 3.664 7.363 4.161 0.246 8.046 5.521 7.473 7.178 5.649
Output
0.815
According to the desired additivity, the problem can be transformed into the sum of all people's expected time.
The probability of each person in each position must be 1 / n, so calculate and accumulate the time required for each person in each position, and finally divide by n.
The following specific derivation is borrowed from: LB_tq
1 #include <bits/stdc++.h> 2 typedef long long LL; 3 #define pb push_back 4 const int INF = 0x3f3f3f3f; 5 const double eps = 1e-8; 6 const int mod = 1e9+7; 7 const int maxn = 1e5+10; 8 using namespace std; 9 10 double c[1005]; 11 double d[1005]; 12 13 int main() 14 { 15 #ifdef DEBUG 16 freopen("sample.txt","r",stdin); //freopen("data.out", "w", stdout); 17 #endif 18 19 int n; 20 double v,u; 21 scanf("%d %lf %lf",&n,&v,&u); 22 for(int i=1;i<=n;i++) 23 scanf("%lf",&c[i]); 24 for(int i=1;i<=n;i++) 25 scanf("%lf",&d[i]); 26 double ans=0.0; 27 for(int i=1;i<=n;i++) 28 { 29 for(int j=1;j<=n;j++) 30 { 31 ans+=u/(c[i]-(j-1)*d[i]-v); 32 } 33 } 34 printf("%.3f\n",ans); 35 36 return 0; 37 }
-