跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1390. The Sum of the k-th Powers

  • ID: 1396
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:挑战
  • 上传者:
  • 数学
  • 挑战
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

The Sum of the k-th Powers

题目描述

F. The Sum of the k-th Powers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
Input
4 1
Output
10
Input
4 2
Output
30
Input
4 3
Output
100
Input
4 0
Output
4

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 893 题。保留原作者与原赛事署名。