8314: HDU4089 - Activation
[Creator : ]
Description
After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazy fan, and luckily he got the first release. Now he is at home, ready to begin his journey.
But before starting the game, he must first activate the product on the official site. There are too many passionate fans that the activation server cannot deal with all the requests at the same time, so all the players must wait in queue. Each time, the server deals with the request of the first player in the queue, and the result may be one of the following, each has a probability:
1. Activation failed: This happens with the probability of $p_1$. The queue remains unchanged and the server will try to deal with the same request the next time.
2. Connection failed: This happens with the probability of $p_2$. Something just happened and the first player in queue lost his connection with the server. The server will then remove his request from the queue. After that, the player will immediately connect to the server again and starts queuing at the tail of the queue.
3. Activation succeeded: This happens with the probability of $p_3$. Congratulations, the player will leave the queue and enjoy the game himself.
4. Service unavailable: This happens with the probability of $p_4$. Something just happened and the server is down. The website must shutdown the server at once. All the requests that are still in the queue will never be dealt.
Tomato thinks it sucks if the server is down while he is still waiting in the queue and there are no more than K-1 guys before him. And he wants to know the probability that this ugly thing happens.
To make it clear, we say three things may happen to Tomato: he succeeded activating the game; the server is down while he is in the queue and there are no more than K-1 guys before him; the server is down while he is in the queue and there are at least K guys before him.
Now you are to calculate the probability of the second thing.
有 n 个人排队等着在官网上激活游戏。Tomato排在第 m 个。
对于队列中的第一个人。有以下情况:
1、激活失败,留在队列中等待下一次激活,概率为 $p_1$。
2、失去连接,出队列,然后排在队列的最后,概率为 $p_2$。
3、激活成功,离开队列,概率为 $p_3$。
4、服务器瘫痪,服务器停止激活,所有人都无法激活了。
求服务器瘫痪时 Tomato 在队列中的位置 $\leq K$ 的概率。
But before starting the game, he must first activate the product on the official site. There are too many passionate fans that the activation server cannot deal with all the requests at the same time, so all the pla
1. Activation failed: This happens with the probability of $p_1$. The queue remains unchanged and the server will try to deal with the same request the next time.
2. Connection failed: This happens with the probability of $p_2$. Something just happened and the first pla
3. Activation succeeded: This happens with the probability of $p_3$. Congratulations, the pla
4. Service unavailable: This happens with the probability of $p_4$. Something just happened and the server is down. The website must shutdown the server at once. All the requests that are still in the queue will never be dealt.
Tomato thinks it sucks if the server is down while he is still waiting in the queue and there are no more than K-1 guys before him. And he wants to know the probability that this ugly thing happens.
To make it clear, we say three things may happen to Tomato: he succeeded activating the game; the server is down while he is in the queue and there are no more than K-1 guys before him; the server is down while he is in the queue and there are at least K guys before him.
Now you are to calculate the probability of the second thing.
有 n 个人排队等着在官网上激活游戏。Tomato排在第 m 个。
对于队列中的第一个人。有以下情况:
1、激活失败,留在队列中等待下一次激活,概率为 $p_1$。
2、失去连接,出队列,然后排在队列的最后,概率为 $p_2$。
3、激活成功,离开队列,概率为 $p_3$。
4、服务器瘫痪,服务器停止激活,所有人都无法激活了。
求服务器瘫痪时 Tomato 在队列中的位置 $\leq K$ 的概率。
Input
There are no more than 40 test cases.
Each case in one line, contains three integers and four real numbers: $N, M\ (1 \leq M \leq N \leq 2,000),\ K\ (K \ge 1),\ p_1, p_2, p_3, p_4\ (0 \leq p_1, p_2, p_3, p_4 \leq 1, p_1 + p_2 + p_3+p_4 = 1)$, indicating there are N guys in the queue (the positions are numbered from 1 to N), and at the beginning Tomato is at the M-th position, with the probability $p_1, p_2, p_3, p_4$ mentioned above.
Each case in one line, contains three integers and four real numbers: $N, M\ (1 \leq M \leq N \leq 2,000),\ K\ (K \ge 1),\ p_1, p_2, p_3, p_4\ (0 \leq p_1, p_2, p_3, p_4 \leq 1, p_1 + p_2 + p_3+p_4 = 1)$, indicating there are N guys in the queue (the positions are numbered from 1 to N), and at the beginning Tomato is at the M-th position, with the probability $p_1, p_2, p_3, p_4$ mentioned above.
Output
A real number in one line for each case, the probability that the ugly thing happens.
The answer should be rounded to 5 digits after the decimal point.
The answer should be rounded to 5 digits after the decimal point.
Sample 1 Input
2 2 1 0.1 0.2 0.3 0.4
3 2 1 0.4 0.3 0.2 0.1
4 2 3 0.16 0.16 0.16 0.52
Sample 1 Output
0.30427
0.23280
0.90343