Description
Dear Uncle Jack is willing to give away some of he collectable CDs to his nephews. Among the titles can find very rare albums of hard Rock, classical Music, reggae and much more; Each title was considered to be unique. Last week he is listening to one of his favorite songs, Nobody's fool, and realized that it would is prudent to Be aware of the many ways he can give away the CDs among some of his nephews.
So far he have not made the the the amount of CDs and the number of nephews. Indeed, a given nephew may receive no CDs at all.
Dear Uncle Jack, given the total number of CDs and the number of nephews, to calculate the number of different Ways to distribute the CDs among the nephews.
Input
The input consists of several test cases. Each test case was given in a single line of the input by, space separated, integers n (1≤ n ≤10) and C3>d (0≤ D ≤25), corresponding to the number of nephews and the number of CDs respectively. The end of the test cases is indicated with N = D = 0.
Output
The output consists of several lines, one per test case, following the order given by the input. Each line have the number of all possible ways to distribute D CDs among N nephews.
Sample Input
1 203 100 0
Sample Output
159049
Ask N^d. Large number, Java, the large number of C + + template is really no love, decisive JAVA.
Import java.io.*;import java.math.*;import java.util.*;p ublic class Main {public static void Main (string[] arges) { C1/>biginteger N; int D; Scanner cin = new Scanner (system.in); while (Cin.hasnext ()) { n=cin.nextbiginteger (); D=cin.nextint (); if (N.compareto (Biginteger.zero) ==0&&d==0) break ; BigInteger ans; Ans=n.pow (d); System.out.println (ANS);// System.out.println ();}} }
POJ 3199 Uncle Jack (Java Practice)