UJ - Uncle Jack


Dear Uncle Jack is willing to give away some of his collectable CDs to his nephews. Among the titles you can find very rare albums of Hard Rock, Classical Music, Reggae and much more; each title is considered to be unique. Last week he was listening to one of his favorite songs, Nobody’s fool, and realized that it would be prudent to be aware of the many ways he can give away the CDs among some of his nephews.

So far he has not made up his mind about the total amount of CDs and the number of nephews. Indeed, a given nephew may receive no CDs at all.

Please help 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 is given in a single line of the input by, space separated, integers N (1 <= N <= 1000) and D (0 <= D <= 2500), 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 has the number of all possible ways to distribute D CDs among N nephews.

Example

Input:
1 20
3 10
0 0

Output:
1
59049

hide comments
eightnoteight: 2015-01-03 17:13:36

the derivation is beautiful...

[bitthal]: 2014-12-31 14:25:03

why my code which is not able to pass ur test cases is accepted.....

ViKku: 2014-12-25 06:43:21

Got AC without implementation of big integer in C

surayans tiwari(http://bit.ly/1EPzcpv): 2014-12-24 17:45:09

595 bytes of c++ code ,, can't figure out how to reduce further, help!
<snip>

Last edit: 2023-09-22 20:33:37
Swapnil Borse: 2014-12-18 15:16:07

JACK JACK JACK!!!
Use Big integers if implementing in c/c++
Taught me a new thing. Thanks Jackkk :P

mayank: 2014-10-29 06:25:53

Mistook CDs to be identical!

Sudarshan K: 2014-07-24 21:52:40

Strange: Using math.pow gave NZEC , using built-in pow AC. These pythonic things.

Last edit: 2014-07-24 21:52:59
excursionist: 2014-06-21 03:04:30

GOT AC!!!
with python 2.7 and java :D
easy one but dont try with c,c++
my 75th spoj ;)

Raj Mehta: 2014-06-11 18:19:07

how to do it in c/c++
within 512B

pvkcse: 2014-05-18 16:15:20

Got Ac with fist attempt in python 3...enjoyed solving...!!!


Added by:Camilo Andrés Varela León
Date:2006-10-25
Time limit:1s
Source limit:512B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:XX Colombian National Programming ACM 2006