CODEM2 - Problem2


Two boxes contain the same total numbers of balls having some blacks and some whites in each. From each box "n" number of balls are drawn with replacement. Find the number of white balls in box A if composition of box B is given and such that probability that all white balls are drawn from box A is equal to the probability that the drawing from box B is either all whites or all blacks for the given number of drawings.

Input

T: number of test cases
Next T lines contain 3 integers n, x, y.

Output

For each test case print in new line "impossible" if it is not possible to find number of white balls in box A else print number of white balls.

Constraints

1 <= n <= 1000
1 <= x, y <= 1000
x = number of white balls in box B, y = number of black balls in box B

Example

Input:
1
2 3 4 Output: 5

hide comments
bidoteima: 2023-08-13 15:48:08

This is an unsolvable problem, many people might've passed tests due to weak tests.
See this link: https://mathoverflow.net/questions/27305/a-binomial-generalization-of-the-flt-bombieris-napkin-problem?_gl=1*17jhilp*_ga*Njg5ODEwMDEyLjE2ODY1Nzg1NTQ.*_ga_S812YQPLT2*MTY5MTkzMDkxOS4xNi4xLjE2OTE5MzM5MTEuMC4wLjA.

Last edit: 2023-08-13 15:50:02
mahilewets: 2017-09-08 21:41:45

P(A, W) is probability that all n balls drawn from box A are white
P(B, W) is probability that all n balls drawn from box B are white P(B, B) is probability that all n balls drawn from box B are black

Statement says P(A, W) =P(B, W) + P(B, B)

zubenkoivan: 2017-08-09 18:38:46

please add more test cases

racsosabe16: 2017-06-22 20:00:04

I couldn't understand correctly the problem >:V


Added by:Bhavik
Date:2014-02-04
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own problem(for CODE MARATHON)