P23083 [AtCoder] [ABC021D] Multi-dimensional Loop
提高-
题目描述

Problem Description

Takahashi, a new recruit, has been assigned to a department as a rookie programmer. His first task is to optimize a program represented by the following pseudocode:

```

n←(standard input)
ans←0
for i=1..n
for j=i..n
ans ← ans+1
display the value of ans


This task is a piece of cake for Takahashi. By considering the number of iterations of the inner loop for each $ i $ and using the summation formula, he finds that $ ans=n+n-1+…+1=n(n+1)/2 $. Using this, he can quickly find the answer.

His success has dramatically increased the expectations from his department. Therefore, his boss has assigned him another task.

The new task involves optimizing a program where the depth of nested for loops is $ k $:

 ```

n←(standard input)
k←(standard input)
ans←0
for a_1=1..n
  for a_2=a_1..n
    for a_3=a_2..n
      …
      for a_k=a_{k-1}..n // assume a_0=1
        ans ← ans+1
display the value of ans

Even Takahashi is a bit stumped by this. He cannot use the summation formula here.

After some thought, he realizes that the output of this program is equal to the number of integer tuples $ (a_1,a_2,…,a_k) $ such that $ 1≦a_1≦a_2≦…≦a_k≦n $. However, he cannot think of a way to count such tuples.

As his colleague, you decide to help him by writing a program to solve this challenge. Note that the answer can be very large, so instead of ans, output the remainder of ans divided by $ 1,000,000,007(=10^9+7) $.

Input Format

The input is given from the standard input in the following format:

$ n $ $ k $

  • The first line contains an integer $n\ (1\ ≦\ n\ ≦\ 10^5)$.
  • The second line contains an integer $k\ (1\ ≦\ k\ ≦\ 10^5)$.

Output Format

Output one line containing the final value of ans in the second program, modulo $ 1,000,000,007 $.

Do not forget the newline at the end.

Sample Input and Output

Sample Input #1

10
2

Sample Output #1

55

Sample Input #2

10
3

Sample Output #2

220

Sample Input #3

10
4

Sample Output #3

715

Sample Input #4

400
296

Sample Output #4

546898535

Sample Input #5

100000
100000

Sample Output #5

939733670

Notes/Hints

Partial Points

This problem has partial points.

  • If you correctly solve the dataset where $ 1≦n≦1000 $ and $ 1≦k≦1000 $, you will earn $ 99 $ points.
  • If you correctly solve all datasets including the above, you will earn an additional $ 1 $ point.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
10 2
样例输出
55