Welcome to ZOJ
 Contests Information Problems Runs Statistics Ranklist Clarification
114 - ZOJ 10th Anniversary Contest - B
Back to the Past

Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

Recently poet Mr. po encountered a serious problem, rumor said some of his early poems are written by others. This brought a lot of trouble to Mr. po, so one day he went to his best friend MasterO for help. MasterO handed over a small wooden box with a silent smile. Mr. po checked the box, a word "YGBH" carved on the side. "The box can take you back to the past," MasterO said, "so you can get any evidence you need. But, before that, you need some patience."

There are N tiny dark holes on both sides of the box (2N holes in total). Every day, for each hole, there is a possibility P to successfully absorb the power of moon and then magically sparkle. The possibilities among holes are independent in each day. Once a hole sparkles, it will never turn dark again. The box only works when there are no less than M sparkling holes on each side of the box. The question is that what is the expected number of days before the box is available.

#### Input

The input consists of several test cases. For each case there are 3 numbers in a line: N, M, P. 1 ≤ N ≤ 50, 1 ≤ MN, 0.01 ≤ P ≤ 1. A case with three zeros indicates the end of the input.

#### Output

For each test case, output the expected number of days, accurate up to six decimal places.

```2 1 1
1 1 0.5
0 0 0
```

#### Sample Output

```1.000000
2.666667
```

Author: ZHENG, Jianqiang
Submit    Status