hdu 4762 公式 java】的更多相关文章

n/(n)^(m-1) import java.io.*; import java.math.*; import java.util.*; public class Main { static BigInteger gcd(BigInteger a,BigInteger b) { if(b.equals(BigInteger.ZERO))return a; else return gcd(b,a.mod(b)); } public static void main(String arg[]) {…
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…
题目链接: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-…
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…
题目链接: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),然后分子分母同除以该数就可以了. 这里有两个方法可以推出来.…
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…
题目链接: Series 1 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 423    Accepted Submission(s): 146 Problem Description Let A be an integral series {A1, A2, . . . , An}. The zero-order series o…
latex_word 主要目的:     给大家分享一个我的原创作品:latex转为word公式(omml)工具 [java] 此工具主要用于将含有latex公式的文本下载成word时,将latex转换为word格式的公式 如果这不是你想要的你走吧,不要给我打赏 创作背景:  (纯粹扯淡,可以忽略)      由于惨品要求要将html格式且带有latex公式的试题下载成word版的试卷(需求很合理,心想好难啊我的power不够啊,不能怯场, 微笑着说‘预估需要两周的时间’) html转到word…
大菲波数 Problem Description Fibonacci数列,定义如下:f(1)=f(2)=1f(n)=f(n-1)+f(n-2) n>=3.计算第n项Fibonacci数值.   Input 输入第一行为一个整数N,接下来N行为整数Pi(1<=Pi<=1000).   Output 输出为N行,每行为对应的f(Pi).   Sample Input 5 1 2 3 4 5   Sample Output 1 1 2 3 5   import java.math.BigInt…