首页 > TAG信息列表 > CF622F

CF622F The Sum of the k-th Powers

IX.CF622F The Sum of the k-th Powers 看上去这题是上一题的弱化版,但其实不是——上题我们要筛出式子,但是这题我们要保证复杂度。 首先,我们打算选取\(0\sim k+1\),共\(k+2\)个点进行插值。我们设\(f_x=\sum\limits_{i=0}^x i^k\)。 则由拉格朗日插值公式,我们有答案等于 \[\sum\lim

【CF622F】The Sum of the k-th Powers

题目 题目链接:https://codeforces.com/problemset/problem/622/F 求 \[\sum^{n}_{i=1}i^k \]\(n\leq 10^9,k\leq 10^6\)。 思路 可以证明这个东西是关于 \(n\) 的 \(k+1\) 次多项式。不会证太菜了当结论记。 所以可以直接将 \(i=1\sim k+2\) 带进去,直接上拉格朗日插值可以做到 \(O

luolgu CF622F The Sum of the k-th Powers |拉格朗日插值

题意翻译 求 \(\sum_{i=1}^ni^k \bmod (10^9+7)\) #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int N=1e6+5,mod=1e9+7; #define int long long int n,k,y[N]; inline int ksm(int x,int

CF622F The Sum of the k-th Powers (拉格朗日插值)

题目: 输入n,k求\(\sum_{i = 1}^{n} i^k\) 。 题解: 这个和是k+1次的多项式,我们用k+2个值就可以唯一确定这个多项式,计算f(n)即可 int main() { scanf("%lld%lld",&n,&k); pre[0] = suf[k + 3] = fac[0] = 1; for(int i = 1; i <= k + 2; ++ i) pre[i] = pre[i - 1] * (n - i) % m

CF622F 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). 1 #include"bits/stdc++.

CF622F The Sum of the k-th Powers(拉格朗日插值)

题意 给出 \(n,k\) , \(n\le10^9,k\le10^6\) ,求 \(\sum_{i=1}^n i^k(mod\;10^9+7)\) 题解 自然数幂次和,是一个\(k+1\)次多项式,那么算出\(k+2\)个值然后差值就行了 //minamoto #include<bits/stdc++.h> #define R register #define fp(i,a,b) for(R int i=a,I=b+1;i<I;++i) #define f