MAY99_4 - Rachu


Rachu is very happy today because its his birthday :D and he has a birthday party at home with 'r' friends.

He went to market to purchase something to eat. (He is really fond of eating :P ). At the shop he found muffins at a very reasonable price (ohh!! he loves muffins ;) ). He bought 'n' muffins from the shop.

After reaching home he is wondering that in how many ways he can distribute these muffins between his friends.

He shouldn't be rash so he would give at least 1 muffin to each friend. For rest of the muffins left he can distribute it in any manner. He is still wondering the no. of ways in which he can distribute these muffins.

Help him out by writing a code which calculates the number of ways the muffins could be distributed and print "-1" (quotes for clarity) if its impossible for him to distribute the muffins.

Consider each muffin as similar. The number of ways could go very large so output the result after taking a mod with 10000007.

Input

The input consists of 2 integers: n - the number of muffins, and r - The number of friends

Output

The required answer modulo 10000007.

Constraints

1 <= n, r <= 100

Example

Input:
2 1

Output:
1
Input:
4 2

Output:
3

Explanation

In 1st case he has 2 muffins and called only 1 friend so he gave both the muffins to him.

In 2nd case he 1st give 1 muffin each to both. Then he can give 0 muffin to 1st friend and 2 to the 2nd or 1 muffin to each or 2 muffins to 1st friend and 0 to the 2nd.


hide comments
kuderrahul: 2023-03-18 15:43:42

don't look for formula rather workout for some examples and you will find recurrence relation

kelvin_0179: 2020-05-13 19:22:36

modulo is not 10^9 +7 but 10^7 + 7.... cost me 2 WA XD

amansahu112: 2020-05-01 10:13:36

binomial cofficient dp

tarun_28: 2020-03-10 13:06:28

simple Combinatorics:)
.23s with PyPy

shubham97361: 2019-04-16 21:47:44

Since we have to give at least one muffin to each person we are left with n-m muffins and m people.Now, use the formula how to distribute n identical objects in m persons using dp.

kshubham02: 2018-12-15 22:54:59

Kripaya problem statement me chutiyaap thoda kam karen.

cryo: 2018-06-05 16:44:16

remember '-1'

viratian_070: 2017-07-01 06:42:53

easy stuff...but remember printing "-1"

heisenberg0820: 2017-06-22 15:19:02

100th :)

sas1905: 2017-05-23 17:12:25

when n<r print -1 not zero costed me two WA's..hardly 5-6 lines in python..


Added by:Mayank Tuteja
Date:2013-01-18
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET
Resource:Gunjit Agrawal