Cut the Cake
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1102 Accepted Submission (s): 540
Problem Descriptionmmm got a big big big cake, and invited all she 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 th EY 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 randoml Y one by one. After then, MMM would cut the cake into M pieces of sector with equal size and shape (the last one came to the party would There is no cake to eat), and choose one piece first. MMM wants to know the probability so she can get all N strawberries, can I help her? As the cake is so big and all strawberries on it could be treat as points.
Inputfirst line was the integer t, which means there is t cases.
For each case, a integers M, N indicate the number of her friends and the number of strawberry.
(2 < M, N <=, T <= 400)
Outputas the probability could is very small, you should output the probability in the form of a fraction in lowest terms. For each case, the output of the probability. Please see the sample for more details.
Sample Input23 33 4
Sample OUTPUT1/34/27 Test Instructions: cut m-block cake, to find the probability of n strawberries all on a piece of cake. Formula: n/(n-1 of M); Harvest: Understand the next large number of java. Simplification can be used with two numbers of least common multiple.
Importjava.math.*;ImportJava.util.*; Public classMain { Public Static voidMain (string[] args) {//TODO auto-generated Method StubScanner in =NewScanner (system.in); intt =In.nextint (); while(t-->0) {BigInteger m=In.nextbiginteger (); intn =In.nextint (); M=m.pow (n-1); BigInteger b=biginteger.valueof (n); BigInteger A; A=M.GCD (b); BigInteger C=M.divide (a); BigInteger C2=B.divide (a); System.out.println (C2+ "/" +c); } }}
HDU4762 (Java large number)