大整数运算(加法,减法,除法,求余,求最大公约数)

Another lottery

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 2^i 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 ith such line contains m non-negative integers c1, ..., cm, where cj (1 ≤ j ≤ m) 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 10^30.

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

 

Sample Output

1 / 4
1 / 3
5 / 12
0 / 1
0 / 1
1 / 1
我们OJ上的一道从HDU拉过来的题,改了改,把数据范围加大,就成了高精度运算的题目了。
写了好久,而且写好时发现怎么也过不了,用这个高精度的代码去HDU上提交了一下,AC了,
然后就抓出服务器上的数据,对比了下,发现原来是原数据错了>.<,好吧,再出数据,再改题
把10^18次方的数据范围也改到10^30次方了,这下只能高精度计算了,也别想着用__int64
了,嘿嘿~
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值