hdu4762 Cut the Cake
来源:互联网 发布:淘宝出现差评会怎么样 编辑:程序博客网 时间:2024/05/29 06:56
Cut the Cake
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10 Accepted Submission(s): 3
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)
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
23 33 4要用大数!import java.io.*;import java.util.Scanner;import java.math.BigInteger;public class Main{public static void main(String str[]){Scanner scanner=new Scanner(System.in);int tcase=scanner.nextInt();while(tcase!=0){tcase--;BigInteger n=scanner.nextBigInteger(10);int m=scanner.nextInt(10);BigInteger bm=BigInteger.valueOf(m);BigInteger ans=n.pow(m-1);BigInteger temp=ans.gcd(bm); System.out.println(""+bm.divide(temp)+"/"+ans.divide(temp)); }}}
- hdu4762 Cut the Cake
- hdu4762 Cut the Cake(高次幂)
- 2013 ACM/ICPC Asia Regional Changchun Online----hdu4762 Cut the Cake
- [概率]Cut the Cake
- Cut The Cake
- HDU 4328 - Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- HDU-4328-Cut the cake
- Cut the Cake(大数)
- HDU 4762 Cut the Cake
- HDU-4762 Cut the Cake
- HDU 4328 Cut the cake
- hdu - 4328 - Cut the cake - dp
- hdu 4762 - Cut the Cake(大数)
- hdu 4762 Cut the Cake(高精度&概率)
- hdu 4762 Cut the Cake(高精度)
- linux powerpc i2c驱动 之 i2c设备层的注册过程
- 《#诗盗#~穿女神装的不一定就是女神,还可能是基友》
- GC日志分析
- 二叉树的非递归遍历
- ubuntu下C++程序编写kate编译执行g++
- hdu4762 Cut the Cake
- AJAX基础
- 字符串扩展
- Java Timer的使用(timer.schedule定时执行)
- 开发笔记 那些年追过的图片(八):PNG,JPEG格式相互转换
- 《#诗盗#~圣鹰猪口日哥》
- Visual Studio 12 技巧
- jstl fmt用法
- JAVA TIMER用法学习