You live in village A, you need a lot of river to another village B to work every day, B on the right side of a, all the river is between a A and a, fortunately, each ship has a free-moving automatic boat,
So just reach the left bank of the river and wait for the boat to come, disembark on the right bank, the ship's speed unchanged after the boat. Now ask what the expected time from A to B is, assuming that the ship's position at the departure is
Randomly distributed. The speed at which people walk on land is 1.
According to the mathematical expectation of linearity, the time for each river is l/v (to the river side of the boat just open) to the 3l/v (to the river side of the boat just off) evenly distributed, so expect to cross the river Time for (l+3l/v)/2= (2*l/v) plus d-sum (L).
1#include <cstdio>2#include <cstring>3 intMain ()4 {5 intn,d,p,l,v,s,j=1;6 Doublesum;7 while(~SCANF ("%d%d",&n,&d))8 {9 if(n==0&&d==0) Break;Tensum=0; Ones=0; A for(intI=0; i<n;i++) - { -scanf"%d%d%d",&p,&l,&v); thesum+=2.0*l/v; -s+=l; - } -printf"Case %d:%.3lf\n\n", j++,sum+ (ds)); + } - return 0; +}
Uva-12230 Crossing Rivers (mathematical expectation)