Preparando MOJI

The Sum of the k-th Powers

2000ms 262144K

Description:

There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees.

Find the value of the sum modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7).

Input:

The only line contains two integers n, k (1 ≤ n ≤ 109, 0 ≤ k ≤ 106).

Output:

Print the only integer a — the remainder after dividing the value of the sum by the value 109 + 7.

Sample Input:

4 1

Sample Output:

10

Sample Input:

4 2

Sample Output:

30

Sample Input:

4 3

Sample Output:

100

Sample Input:

4 0

Sample Output:

4

Informação

Codeforces

Provedor Codeforces

Código CF622F

Tags

math

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:03:42

Relacionados

Nada ainda