hdu 4762 Cut the Cake (大数乘法)】的更多相关文章

Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 300    Accepted Submission(s): 135 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 263    Accepted Submission(s): 113 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1657    Accepted Submission(s): 806 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake tog…
猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; int gcd(int a,int b) { ) return a; return gcd(b,a%b); } BigNum mul(BigNum &a,int b) { BigNum c; int i,len; len=a.len; memset(c.num,,sizeof(c.num)); ) {…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋糕上的概率 Sample Input 2 3 3 3 4   Sample Output 1/3 4/27 分析:计算出这个概率公式为:n/(mn-1),m.n最大为20,mn超出了64位,用到大数,用java容易写出 代码如下: import java.math.BigInteger; impor…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题意:有个蛋糕,切成m块,将n个草莓放在上面,问所有的草莓放在同一块蛋糕上面的概率是多少.2 < M, N <= 20 分析:概率题,公式题.可惜我数学太差,想了好久都想不出来,看了题解还是不太明白怎么算的. 最后的概率公式为:n / (m^(n-1)),然后用高精度就可以了,最后的结果要约分,可以在计算的过程中求gcd(n,m),然后分子分母同除以该数就可以了. 这里有两个方法可以推出来.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. 算法思路:n个草莓在圆形上有一个最左边的,为了好理解,先把假设草莓有1-n的不同编号.  现在从n个草莓中选出一个编号A的放在最左边(这个最左边可以随便放),得到C(n,1)*1.然后把其余的n-1草莓不分先后的放在A的右边角大小为(360)/m的扇形区域内就可以了. 所以概率为 n/(m^(n-…
  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 dec…
Cut the cake Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1250    Accepted Submission(s): 489 Problem Description: Mark bought a huge cake, because his friend ray_sun’s birthday is coming. Ma…
注意题目中的这句话he put the strawberries on the cake randomly one by one,第一次选择草莓其实有N个可能,以某一个草莓为开头,然后顺序的随机摆放,所以最后的概率为n/m^(n-1),最后通过大数模板搞定该题的化简. C++代码 #include<iostream> #include<cstring> #include<cstdio> #include<iomanip> #include<algori…