题目名称 3667. [CF622F] The Sum of the k-th Powers
输入输出 powsum.in/out
难度等级 ★★★☆
时间限制 2000 ms (2 s)
内存限制 256 MiB
测试数据 10
题目来源 Gravatarlihaoze 于2022-05-02加入
开放分组 全部用户
提交状态
分类标签
高等数学
分享题解
通过:1, 提交:1, 通过率:100%
Gravatarlihaoze 100 0.000 s 0.00 MiB C++
关于 The Sum of the k-th Powers 的近10条评论(全部评论)
理解了之后就是拉插模板题 (提示: 注意题目描述中各示例的次数),最后把连乘式展开,维护前缀积和后缀积即可。似乎这一题还有什么斯特林数的解法,不过蒟蒻太蒻 QWQ,只会用拉插
Gravatarlihaoze
2022-05-25 20:13 1楼

3667. [CF622F] The Sum of the k-th Powers

★★★☆   输入文件:powsum.in   输出文件:powsum.out   简单对比
时间限制:2 s   内存限制:256 MiB

【题目描述】


There are well-known formulas: $\displaystyle{\sum_{i = 1}^{n}{i} = {1 + 2 + \ldots + n = \frac{n(n + 1)}{2}}}$ ,


$\displaystyle{\sum_{i = 1}^{n}{i^2} = {1^2 + 2^2 + \ldots + n^2 = \frac{n(n+1)(2n+1)}{6}}}$ ,  $\displaystyle{\sum_{i = 1}^{n}{i^3} = {1^3 + 2^3 + \ldots + n^3 = (\textstyle{\frac{n(n+1)}{2})^2}}}$ . Also


mathematicians found similar formulas for higher degrees.


Find the value of the sum $\displaystyle{\sum_{i = 1}^{n}{i^k} = 1^k + 2^k + \ldots + n^k}$ modulo $10^9 + 7$ (So you should find the remainder after dividing the answer by the value $10^9 + 7$).

【题目翻译】

求 $\displaystyle{\sum_{i = 1}^{n}{i^k} \text{mod} (10^9 + 7)}$

【输入格式】

输入包括两个整数 $n$, $k$ ($1 \le n \le 10^9$, $0 \le k \le 10^9$)。

【输出格式】

输出一个整数 $a$,$a$ 是求和之后的值对 $10^9+7$ 求余的值

【样例输入】

4 1

【样例输出】

10

【样例说明】

$\displaystyle{\sum_{i = 1}^{4}i = 1 + 2 + 3 + 4 = 10}$

【来源】

Codeforces 622F