Submit | All submissions | Best solutions | Back to list |
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
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) |
hide comments