Problem:
Balls and Boxes 5

Balls

Boxes

Any way

At most one ball

At least one ball

Distinguishable

Distinguishable

1

2

3

Indistinguishable

Distinguishable

4

5

6

Distinguishable

Indistinguishable

7

8

9

Indistinguishable

Indistinguishable

10

11

12

Problem

You have $n$ balls and $k$ boxes. You want to put these balls into the boxes.

Find the number of ways to put the balls under the following conditions:

Each ball is not distinguished from the other.

Each box is distinguished from the other.

Each ball can go into only one box and no one remains outside of the boxes.

Each box can contain at most one ball.

Note that you must print this count modulo $10^9+7$.

Input

$n$ $k$

The first line will contain two integers $n$ and $k$.

Output

Print the number of ways modulo $10^9+7$ in a line.

Constraints

$1 \le n \le 1000$

$1 \le k \le 1000$

Sample Input 1

3 5

Sample Output 1

10

Sample Input 2

5 10

Sample Output 2

252

Sample Input 3

100 200

Sample Output 3

407336795

Solution in C# (judge verdict: Accepted)

using static System.Math;
using System;

class M
{
    private const int MOD = 1000000007;
    private readonly int[] _f;
    public int Mul(int a, int b) => (int)(BigMul(a, b) % MOD);
    public M(int n)
    {
        _f = new int[n + 1];
        _f[0] = 1;
        for (int i = 1; i <= n; ++i)
            _f[i] = Mul(_f[i - 1], i);
    }
    public int Fac(int n) => _f[n];
    public int Pow(int a, int m)
    {
        if (m == 0) return 1;
        else if (m == 1) return a;
        var p1 = Pow(a, m / 2);
        var p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
    public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var md = new M(n + k);
        if (n > k) { Console.WriteLine(0); goto exit; }
        var ans = md.Ncr(k, n);
        Console.WriteLine(ans);
        exit:;
    }
}