F. The Sum of the k-th Powers 题目连接: http://www.codeforces.com/contest/622/problem/F 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 shoul…
题目链接 求sigma(i : 1 to n)i^k. 为了做这个题这两天真是补了不少数论, 之前连乘法逆元都不知道... 关于拉格朗日插值法, 我是看的这里http://www.guokr.com/post/456777/, 还挺有趣... 根据题目给出的例子我们可以发现, k次方的通项公式的最高次是k+1次, 根据拉格朗日插值法, 构建一个k+1次的方程需要k+2项. 然后公式是  , 对于这个题, p[i]就是i^k+(i-1)^k+(i-2)^k+.....+1^k, 这部分可以预处理出…
Discription 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 onl…
题目链接 The Sum of the k-th Powers 其实我也不懂为什么这么做的……看了无数题解觉得好厉害哇…… #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) ; ; int v[N], p[N], f[N], r[N], b…
题目链接 题意 : 就是让你求个自然数幂和.最高次可达 1e6 .求和上限是 1e9 分析 :  题目给出了最高次 k = 1.2.3 时候的自然数幂和求和公式 可以发现求和公式的最高次都是 k+1 那么大胆猜测幂为 k 的自然数幂和肯定可以由一个最高次为 k+1 的多项式表示 不会证明,事实也的确如此 此时就变成了一个拉格朗日插值的模板题了 只要先算出 k+2 个值.然后就能确定最高次为 k+1 的多项式 套模板求值即可 当然自然数幂和不止这一种做法.例如伯努利数.斯特林数等 详细可参考 ==…
用的dls的板子,因为看不懂调了好久...果然用别人的板子就是这么蛋疼- -|| num数组0~k+1储存了k+2个值,且这k+2个值是自然数i的k次方而不是次方和,dls的板子自己帮你算和的...搞得我弄了好久 #include <iostream> #include <string.h> #include <cstdio> #include <vector> #include <queue> #include <assert.h>…
题目描述: 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 th…
题目链接:Codeforces 396B On Sum of Fractions 题解来自:http://blog.csdn.net/keshuai19940722/article/details/20076297 题目大意:给出一个n,ans = ∑(2≤i≤n)1/(v(i)*u(i)), v(i)为不大于i的最大素数,u(i)为大于i的最小素数, 求ans,输出以分式形式. 解题思路:一開始看到这道题1e9,暴力是不可能了,没什么思路,后来在纸上列了几项,突然想到高中时候求等差数列时候用到…
codeforces 963A Alternating Sum 题解 计算前 \(k\) 项的和,每 \(k\) 项的和是一个长度为 \((n+1)/k\) ,公比为 \((a^{-1}b)^k\) 的等比数列. 当公比为 \(1\) 时,不能用等比数列求和公式. 什么时候公比为 \(1\) ? 当 \(a=b\) 时,\(a^{-1}b=1(mod\ p)\) 当 \(a=p-b\) 时,\(a^{-1}b=(p-b)^{-1}b=-1(mod\ p)\),如果此时 \(k\) 是偶数,公比就…
The Sum of the k-th Powers 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).…