Shopping Spree!

4

5 votes
Combinatorics, Dynamic Programming, Easy
Problem

Today, Vasya has decided to go to the Shopping Centre to buy some stuff for the upcoming College Farewell. On reaching the place, he found a fascinating shop that has an unlimited quantity of each item they sell. The shop has N different types of items. However, here Vasya has a fixed budget and can buy a maximum of K items. He can buy any amount of items 1 and K.

He can buy an arbitrary quantity of each item. There is no restriction on different items having different quantities. Now, Vasya wonders the number of different ways in which he can shop today. Two ways are considered different if the quantity of at least 1 of the items purchased is different. Vasya finds this task too hard to complete and requires your help. You need to find the answer and print it. As the answer may be large, print it Modulo 109+7.

Input Format:

The first and only line of input contains 2 integers N and K.

Output Format:

Print the required answer on a single line.

Constraints:

1N1000

1K1000

Note:

Vasya needs to purchase atleast a single item.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Let's name the items to be R, G and B. So, Vasya can shop in the following ways:

  1. R
  2. G
  3. B
  4. RR
  5. GG
  6. BB
  7. RG
  8. GB
  9. RB

So, the number of possible ways here is 9, so the answer = 9%(109+7)=9.

Editor Image

?