#CF622F. The Sum of the k-th Powers

The Sum of the k-th Powers

The Sum of the k-th Powers

  • 时间限制:2 秒
  • 内存限制:250 MiB

题目描述

已知幂次和公式 ∑i=1ni=n(n+1)/2\sum_{i=1}^n i=n(n+1)/2、∑i=1ni2=n(n+1)(2n+1)/6\sum_{i=1}^n i^2=n(n+1)(2n+1)/6、∑i=1ni3=n2(n+1)2/4\sum_{i=1}^n i^3=n^2(n+1)^2/4。现在给定 n,kn,k,求 ∑i=1nik\sum_{i=1}^n i^k 对 109+710^9+7 取模的结果。

输入格式

一行两个整数 n,kn,k。

输出格式

输出一个整数,表示所求的余数。

样例输入 1

4 1

样例输出 1

10

样例输入 2

4 2

样例输出 2

30

样例输入 3

4 3

样例输出 3

100

样例输入 4

4 0

样例输出 4

4

数据范围

对于所有测试数据,保证:

  • 1≤n≤1091\le n\le10^9;
  • 0≤k≤1060\le k\le10^6。

附件

powers.zip