22724_Anotherlottery

2022-5-16 18:22| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506895731100-Problem List-采集的数据-后羿采集器.html

Pro.ID

22724

Title

Another lottery

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22724

AC

12

Submit

18

Ratio

66.67%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Even in times of an economic crisis, people in Byteland still like to participate in lotteries. With a bit of luck, they might get rid of all their sorrows and become rich.

    The most popular lottery in Byteland consists of m rounds. In each round, everyone can purchase as many tickets as he wishes, and among all tickets sold in this round, one ticket is chosen randomly, each one with the same probability. The owner of that ticket wins the prize money of this round. Since people in Byteland like powers of 2, the prize money for the winner of round i amounts to 2i Bytelandian Dollars.

    Can you determine for each participant in the lottery the probability that he will win more money than anybody else?

    输入

    The input consists of several test cases. Each test case starts with a line containing two integers n and m, the number of participants in the lottery and the number of rounds in the lottery. You may assume that 1 ≤ n ≤ 10000 and 1 ≤ m ≤ 30.

    The following n lines contain the description of the tickets bought by the participant. The i-th such line contains m non-negative integers c1, ..., cm, where cj (1 ≤ jm) is the amount of tickets of round j bought by partipant i. The total number of tickets sold in each round is between 1 and 109.

    The input ends with a line containing 2 zeros.

    输出

    Description

    Even in times of an economic crisis, people in Byteland still like to participate in lotteries. With a bit of luck, they might get rid of all their sorrows and become rich.

    The most popular lottery in Byteland consists of m rounds. In each round, everyone can purchase as many tickets as he wishes, and among all tickets sold in this round, one ticket is chosen randomly, each one with the same probability. The owner of that ticket wins the prize money of this round. Since people in Byteland like powers of 2, the prize money for the winner of round i amounts to 2i Bytelandian Dollars.

    Can you determine for each participant in the lottery the probability that he will win more money than anybody else?

    Input

    The input consists of several test cases. Each test case starts with a line containing two integers n and m, the number of participants in the lottery and the number of rounds in the lottery. You may assume that 1 ≤ n ≤ 10000 and 1 ≤ m ≤ 30.

    The following n lines contain the description of the tickets bought by the participant. The i-th such line contains m non-negative integers c1, ..., cm, where cj (1 ≤ jm) is the amount of tickets of round j bought by partipant i. The total number of tickets sold in each round is between 1 and 109.

    The input ends with a line containing 2 zeros.

    Output

    For each test case, print n lines of output, where line i contains the probability as a reduced fraction that participant i wins the most money. See the sample output for details.

    Sample Input

    5 4
    3 1 2 3
    3 1 2 4
    3 1 3 5
    4 4 4 0
    5 5 0 0
    1 1
    1
    0 0

    Sample Output

    1 / 4
    1 / 3
    5 / 12
    0 / 1
    0 / 1
    1 / 1

    Source

    样例输入

    5 4
    3 1 2 3
    3 1 2 4
    3 1 3 5
    4 4 4 0
    5 5 0 0
    1 1
    1
    0 0

    样例输出

    1 / 4
    1 / 3
    5 / 12
    0 / 1
    0 / 1
    1 / 1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部