之前的中文题意与测试数据有歧义,现把题目内容改为英文原题。
Xiaoming lives in a village but his girl friend lives in another village. He decided to follow the straight path between his house (A) and girl friend's house (B), but there are several rivers he needs to cross. Assume B is to the right of A, and all the rivers lie between them.
Fortunately, there is one "automatic" boat moving smoothly in each river. When he arrives the left bank of a river, just wait for the boat, then go with it. He is so slim that carrying him does not change the speed of any boat.
Days and days after, he came up with the following question: assume each boat is independently placed at random at time 0, what is the expected time to reach B from A? His walking speed is always 1.
To be more precise, for a river of length L, the distance of the boat (which could be regarded as a mathematical point) to the left bank at time 0 is uniformly chosen from interval [0, L], and the boat is equally like to be moving left or right, if it’s not precisely at the river bank.