Decide whether some day total D up to N and overall total G can yield exact win rates PD and PG.
Medium5Number theoryBrute forceNo attempts yetTime limit5sMemory limit512 MBI played D games of FreeCell today, where D > 0. Each game of FreeCell ends in one of two ways: I win, or I lose. I have been playing for many years, and I have played G games in total so far, so G ≥ D.
At the end of the day I open the statistics screen to see how well I played. It says that I won exactly PD percent of the D games I played today, and exactly PG percent of the G games I have ever played. Both percentages are exact, with no rounding at all. I do not remember how many games I played today (D), and I do not remember how many games I have played in total (G). All I know is that I could not have played more than N games today, so D ≤ N.
Decide whether the two percentages on the screen are possible, or whether the statistics calculator is broken.
The first line contains the number of test cases, T. Each of the next T lines contains three integers N, PD and PG, separated by spaces.
For each test case, print one line in the form Case #x: y, where x is the test case number starting from 1, and y is Possible if both percentages can hold at the same time, or Broken otherwise.
Take N = 9, PD = 80, PG = 56. If I played 5 games today (D = 5) and 25 games in total (G = 25), then I won 4 games today, which is 80% of 5, and 14 games in total, which is 56% of 25. Both percentages come out exact with no rounding, so this case is possible.