Another Lottery
Time limit1sMemory limit256 MB
Each of n players buys tickets across m rounds; round j pays 2^j to one random ticket. For each player, print the reduced fraction for the probability of winning strictly more money than everyone else.
- Level
Medium7 of 10
- Topics
- Probability, Math, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
Even in times of economic crisis, the people of Byteland still enjoy playing lotteries. With a bit of luck they might shed all their worries and become rich.
The most popular lottery in Byteland consists of rounds. In each round everyone may buy as many tickets as they wish, and among all tickets sold in that round exactly one is drawn at random, each ticket with equal probability. The owner of that ticket wins the prize money of the round. Because the people of Byteland love powers of two, the prize money for the winner of round is Bytelandian Dollars.
For each participant, determine the probability that they win more money than anybody else.
Input
The input consists of several test cases. Each test case begins with a line containing two integers and : the number of participants and the number of rounds (, ).
The next lines describe the tickets bought by the participants. The -th of these lines contains non-negative integers , where () is the number of tickets participant bought in round . The total number of tickets sold in each round is between and .
The input ends with a line containing two zeros.
Output
For each test case, print lines. Line contains the probability, as a reduced fraction, that participant wins the most money. Print each fraction in the form numerator / denominator with a single space on each side of the slash (for example 1 / 4; a probability of zero is printed as 0 / 1).