KPGAME - A game with probability

题意翻译

### 描述 Alice 和 Bob 在玩一个游戏。有 $n$ 个石子在这里,Alice 和 Bob 轮流投掷硬币,如果正面朝上,则从 $n$ 个石子中取出一个石子,否则不做任何事。取到最后一颗石子的人胜利。Alice 在投掷硬币时有 $p$ 的概率投掷出他想投的一面,同样,Bob 有 $q$ 的概率投掷出他相投的一面。 现在 Alice 先手投掷硬币,假设他们都想赢得游戏,问你 Alice 胜利的概率为多少。 ### 输入格式 第一行一个正整数 $t$,表示数据组数。 对于每组数据,一行三个数 $n,p,q$。 ### 输出格式 对于每组数据输出一行一个实数,表示 Alice 胜利的概率,保留 $6$ 位小数。 ### 样例输入 1 1 0.5 0.5 ### 样例输出 0.666667 ### 数据范围 $1\leqslant t\leqslant 50$; $0.5\leqslant p,q\leqslant 0.99999999$; 对于 $100\%$ 的数据 $1\leqslant n\leqslant 99999999$。 翻译 by @[Dying_Light](/user/51477) @[aiyougege](/user/39067)

题目描述

Alice and Bob play the following game. First, they collect N small stones and put them together in one pile. After that, they throw a coin one by one. Alice starts first. If a player throws heads then he takes exactly one stone from the pile. In case of tails he don't do anything. The one who takes the last stone wins. For each player, his skill of throwing a coin is known (to everyone, including himself and his opponent). More precisely, if Alice wants to throw some specific side of the coin, she always succeeds with probability P. The same probability for Bob is Q. You are to find probability that Alice will win the game if both guys play optimally.

输入输出格式

输入格式


Input starts with a line containing one integer T - a number of test cases (1 <= T <= 50). Then T test cases follow. Each of them is one line with three numbers N, P, and Q separated with a space (1 <= N <= 99999999, 0.5 <= P, Q <= 0.99999999). P and Q have not more than 8 digits after decimal point.

输出格式


For each test case output one line with a probability that Alice will win the game. Your answer must be precise up to 10^-6.

输入输出样例

输入样例 #1

1
1 0.5 0.5

输出样例 #1

0.666666667