TJOI2018 Day2 T3
题意:多次求∑i=1nik
∑
i
=
1
n
i
k
预处理伯努利数即可 复杂度k2
k
2
伯努利数:∑k=0nCkn+1×Bk
∑
k
=
0
n
C
n
+
1
k
×
B
k
计算公式:∑i=1nik=1k+1∑i=1k+1Cik+1×Bk+1−i×(n+1)i
∑
i
=
1
n
i
k
=
1
k
+
1
∑
i
=
1
k
+
1
C
k
+
1
i
×
B
k
+
1
−
i
×
(
n
+
1
)
i
#include#include#include#define ll long longusing namespace std;inline char gc(){ static char now[1<<16],*S,*T; if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;} return *S++;}inline ll read(){ ll x=0,f=1;char ch=gc(); while(!isdigit(ch)) {if (ch=='-') f=-1;ch=gc();} while(isdigit(ch)) x=x*10+ch-'0',ch=gc(); return x*f;}const int mod=1e9+7;const int N=60;ll n,a[N],cha[N];int T,k;inline int inc(int x,int v){return x+v>=mod?x+v-mod:x+v;}inline int dec(int x,int v){return x-v<0?x-v+mod:x-v;}inline int ksm(ll b,int t){static ll tmp;b%=mod; for (tmp=1;t;b=b*b%mod,t>>=1) if (t&1) tmp=tmp*b%mod;return tmp;}int inv[N],c[N][N],b[N];int main(){ freopen("defile.in","r",stdin); freopen("defile.out","w",stdout); inv[1]=1;for (int i=2;i<=55;++i) inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod; T=read();for (int i=0;i<=55;++i) c[i][0]=1;b[0]=1; for (int i=1;i<=55;++i) for (int j=1;j<=i;++j) c[i][j]=inc(c[i-1][j],c[i-1][j-1]); for (int i=1;i<=52;++i){int sum=0; for (int j=0;j
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~