编程介的小学生 2018-12-18 13:03 采纳率: 20.5%
浏览 349
已采纳

一个数列递推求解的问题,C语言数据结构怎么解决这个问题呢?

Problem Description

Flora has many candies, which attract Preston. Flora told Preston "Let's play a game, after the game maybe you can get some candies."

Before the game starts, there is a piece of candy on the table.

Flora prepared a bag, there is p balls in the bag, q balls of them are sky-blue (q<p), and the others are white.

The game will have n rounds. The rule of each round is as follows:

Preston take out a ball from the bag, and write down its color, then put it back into the bag.

We assume that the possibility of taking out every ball is equal.

If the ball is blue, Flora will add a piece of candy on the table.

Otherwise, Flora will put all candies on the table into a new box, then put a new piece of candy on the table.

After n rounds, Flora put all candies on the table into a new box.

Flora told Preston , "you can choose a box,and eat all candies in it".

Of course, Preston will choose the box which has the most candies in it.

Now Preston wants to know the expectation of the number of candies he could eat.

Input

The input consists of multiple testcases.

There is an positive integer T in the first line standing for the number of the testcases.

Next T lines, each line contains 3 integers n,p,q.

1≤T≤10

1≤n≤1500

1≤q<p≤105

Output

For each testcase, output one line, the expectation of the number of candies he could eat.

The output number should be rounded to 3 decimal places.

Sample Input

2
1 2 1
2 2 1

Sample Output

1.500
2.000

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了