POJ 3199 Uncle Jack (Java Practice)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.