hdu4762(数学概率)

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) ,用大数乘法算出即可

时间: 2024-08-06 11:43:36

hdu4762(数学概率)的相关文章

UVA 10491 Cows and Cars 数学 概率

题目链接: https://vjudge.net/problem/UVA-10491 题目描述: 有a头牛, b辆车, 在你的一次选择后主持人会为你打开C扇有牛的门并问你换门还是不换门, 输出总是换门情况下可以获得车的概率 解题思路: 我现在还没有写代码......我不知道我的思路对不对, 但是先说一下, 我们可以分情况来讨论, 然后分情况乘上获得换门情况下获得车的概率, 也就是全概率公式, 情况分成两种, 一开始指着车, 和一开始指着牛 , res = a/(a+b) * b/(a+b-c-1

数学概率题

Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1. Now each turn you throw a perfect 6 sided dice. If you get X in the dice a

两个与π有关的数学概率

一.布丰投针:在一个平面内,有无数条距离为L的平行线,有一根针,针长d,d<L,现在投针,求针与平行线组相交的概率 二.互素问题:在所以正整数中任取两个数,求它们互素的概率 这两个问题提供了两种通过概率求PAI的方法,非常巧妙! 答案稍后给出!

UVA 11971 - Polygon 数学概率

                                    Polygon  John has been given a segment of lenght N, however he needs a polygon. In order to create a polygonhe has cut given segment K times at random positions (uniformly distributed cuts). Now he has K + 1much sh

UVA 11181(数学概率)

有n个人去超市,第i个人买东西的概率为p[i],逛完之后又r个人买了东西,求每个人实际买东西的概率. 条件概率公式的应用,具体分析见算法竞赛入门经典第二版p327 #include <stdio.h> #include <string.h> #include <cmath> #include <algorithm> using namespace std; const int maxn = 100 + 10; double p[maxn],a[maxn];

HDU_5810_数学,概率,方差

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5810 大意:将n个球往m个盒子中投,每个球被投入每个盒子的概率相等,求方差. 看题解说,这是二项分布(二项分布即重复n次独立的伯努利试验.在每次试验中只有两种可能的结果,而且两种结果发生与否互相对立,并且相互独立,与其它各次试验结果无关,事件发生与否的概率在每一次独立试验中都保持不变,则这一系列试验总称为n重伯努利实验,当试验次数为1时,二项分布服从0-1分布.),E(X)=np,D(X)=np(1

lightoj1079(数学概率与期望)

题意: 哈利波特要去抢银行; 现在给出一个概率p,和银行的个数n; 接下去给出每个银行可以抢到的钱,还有抢劫这个银行被抓的概率; 问在被抓的概率小于等于p的情况下,最多抢到多少钱; 思路: 首先我们把被抓的概率转化为可以逃跑的概率; 然后是一个01背包的思想; dp[j] 代表抢劫到 j 元钱,逃跑的概率; 那么dp[j] = max( ( dp[j - m[i]] ) * p[i]) 也就是不抢第i家银行(那么钱就是j - m[i]) 概率就是 dp[j - m[i]]  然后再抢了这家,那么

lightoj1104(数学概率与期望)

题意: 加入一年有n天; 那么至少有几个人,可以保证至少两个人同一天生日的概率大于等于0.5; 思路: 转化一下题意; 就是求所有人生日都不同的概率小于等于0.5(那么至少两个人同一天就是大于等于0,5); 加入一年365天.那么10个人全都不同天生日的概率就是 366/366 * 365/366 * 364/366 .... * 356/366; 就可以得到公式了; 所以我们累乘过去知道小于等于0.5;看累乘几个; #include<cstdio> #include<cstring&g

hdu 4586 Play the Dice 数学 概率

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4586 题意: 给一个n面的骰子,每一面有一个分数,掷到的话可以得到那个分数 其中有m个面,当你掷到这些面的时候可以再掷一次 求得分的数学期望 思路: 每轮得分的期望 乘以 轮数的期望 每轮得分的期望 = 各个面的平均分 = sum / n; 轮数期望 = 1 + m/n + (m/n)^2 + ... = n - m / n 所以ans = sum / (n - m) ,其中 n!=m 要特判一些情