2416. Dice Hard

单点时限: 3.0 sec

内存限制: 256 MB

Johm Mcdnald, a detective with the New Saitama City Police Department, arrive in Tokyo to attempt a Christmas reunion with his estranged wife Folly. Jolly is a member of toy company Nagatomi. She lives a part with John and lives in Tokyo. John is taken to her work place, the high-rise Nagatomi Plaza, to join the Nagatomi Christmas party.

When the party reaches to a climax, 13 terrorists attack to the building and occupy it. Then, the terrorists order Nagatomi company to make a game popular all over the world.

The game requires two dice, one has k1 faces named Die1 and another has k2 faces named Die2. In this game, you cast these two dice simultaneously. And get total value of up-facing numbers as the points. However, if up-facing number ofDie1 is a and up-facing number of Die2 is b, you cannot get any point and your point becomes zero. You cat get points if up-facing number of Die1 is b and up-facing number of Die2 is a. You should start this game from zero point, and the goal of this game is to get n or more points. You can assume that a die does not have faces with same integer. You can also assume that the largest number on a die is the number of its faces and smallest number is one. You can also assume that these dice are fair dice, the probability of rolling each value, 1 through k1 or k2 , is exactly 1/k1 or 1/k2 .

How stupid they are! But we should not agitate them because they have guns. John is a detective, so John decides to negotiate for their order with terrorists in order to accomplish his mission. In the negotiation, John needs to understand this game and have a common topic with terrorists.

Your job is to write a program to calculate the expectation of the number of times that you cast dice.

输入格式

Input consists of multiple test cases. Each test case contains five positive integers n ( n <= 800) , k1 , k2 (4 <= k1, k2 <= 1,000 ) , a ( 1 <= a <= k1 ) , b ( 1 <= b <= k2) in a line.

Input is terminated by a case of n = k1 = k2 = a = b = 0, and it should not be processed.

输出格式

For each test case, you should output the expectation of the number of times in three floating-point numbers rounded off its fourth decimal place.

样例

Input
10 4 4 1 2
1 10 10 8 8
0 0 0 0 0
Output
2.639
1.010

0 人解决,2 人已尝试。

0 份提交通过,共有 15 份提交。

9.9 EMB 奖励。

创建: 15 年,5 月前.

修改: 6 年,7 月前.

最后提交: 14 年,1 月前.

来源: Winter Contest 2008

题目标签