码迷,mamicode.com
首页 > 其他好文 > 详细

hdu4762(数学概率)

时间:2014-09-13 09:25:04      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:acm   hdu   

Cut the Cake

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 885    Accepted Submission(s): 432


Problem Description
MMM got a big big big cake, and invited all her M friends to eat the cake together. Surprisingly one of her friends HZ took some (N) strawberries which MMM likes very much to decorate the cake (of course they also eat strawberries, not just for decoration). HZ is in charge of the decoration, and he thinks that it‘s not a big deal that he put the strawberries on the cake randomly one by one. After that, MMM would cut the cake into M pieces of sector with equal size and shape (the last one came to the party will have no cake to eat), and choose one piece first. MMM wants to know the probability that she can get all N strawberries, can you help her? As the cake is so big, all strawberries on it could be treat as points.
 

Input
First line is the integer T, which means there are T cases.
For each case, two integers M, N indicate the number of her friends and the number of strawberry.
(2 < M, N <= 20, T <= 400)
 

Output
As the probability could be very small, you should output the probability in the form of a fraction in lowest terms. For each case, output the probability in a single line. Please see the sample for more details.
 

Sample Input
2 3 3 3 4
 

Sample Output
1/3 4/27

题意:n颗草莓,把蛋糕分成m块,问选到n颗草莓全在一块蛋糕的概率

思路:公式为n / m^(n-1) ,用大数乘法算出即可

hdu4762(数学概率)

标签:acm   hdu   

原文地址:http://blog.csdn.net/cq_phqg/article/details/39242569

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!