# 躧搿螞 解题报告

591人阅读 评论(0)

f(n)=i=1nik,g(n)=i=1nf(i)

i=0ng(a+id) mod 1234567891

T3$T\le 3$
1k123;0a,n,d123456789$1\le k\le 123; 0\le a,n,d\le 123456789$

g(n)=i=1n(ni+1)ik=(n+1)i=1niki=1nik+1

xk+1(x1)k+1=j=1k+1(1)jxk+1j

(x1)k+1(x2)k+1=j=1k+1(1)jxk+1j

1k+10k+1=j=1k+1(1)j

xk+1=j=1k+1(1)ji=1xik+1j
,移项：
i=1xik=(k+1)1(xk+1+j=2k+1(1)ji=1xik+1j)

ans=j=0n((a+jd+1)i=1a+jdiki=1a+jdik+1)

ans=i=1k+1ak,ij=0n((a+jd+1)(a+jd)i)i=1k+2ak+1,ij=0n(a+jd)i
=i=1k+1ai(j=0n(a+jd)i+1+j=0n(a+jd)i)i=1k+2ak+1,ij=0n(a+jd)i

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
#include<algorithm>
#define Mod 1234567891
typedef long long LL;
LL pow(int a,int b){
LL ans=1,t=a;
for(;b;b>>=1,t=t*t%Mod)
if(b&1)
ans=ans*t%Mod;
return ans;
}
LL ni(int a){
return pow(a,Mod-2);
}
LL C[130][130];
LL xishu[130][130];
LL said[135];
int main(){
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
int k,i,j,T;
for(i=0;i<130;++i)C[i][0]=1;
for(i=1;i<130;++i)
for(j=i;j;--j)
C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
xishu[0][1]=1;
LL niyuan;
int fu;
for(k=1;k<130;++k){
fu=1;
for(j=2;j<=k+1;++j,fu=-fu)
for(i=k+1-j+1;i;--i)
xishu[k][i]=(xishu[k][i]+fu*xishu[k-j+1][i]*C[k+1][j])%Mod;
niyuan=ni(k+1);
xishu[k][k+1]=1;
for(j=k+1;j;--j)xishu[k][j]=(xishu[k][j]*niyuan%Mod+Mod)%Mod;
}

scanf("%d",&T);
LL a,n,d,start,end,fac;
LL ans;
int K;
while(T--){
scanf("%d%I64d%I64d%I64d",&K,&a,&n,&d);
//said
start=a,end=(a+n*d)%Mod;
said[0]=n;
for(k=1;k<=K+2;++k){
start=start*a%Mod,end=end*(a+n*d%Mod)%Mod;
fu=1;
said[k]=(end-start)%Mod;
fac=d*d%Mod;
for(j=2;j<=k+1;++j,fu=-fu,fac=fac*d%Mod)said[k]=(said[k]+fu*fac*C[k+1][j]%Mod*said[k+1-j])%Mod;
said[k]=said[k]*ni((k+1)*d%Mod)%Mod;
}
if(d){
start=a;
++said[0];
for(k=1;k<=K+2;++k,start=start*a%Mod)said[k]=((said[k]+start)%Mod+Mod)%Mod;
}
else{
start=1;
for(k=0;k<=K+2;++k,start=start*a%Mod)said[k]=(n+1)*start%Mod;
}
//cal first
ans=0;
for(i=1;i<=K+2;++i)ans=(ans+xishu[K+1][i]*said[i])%Mod;
ans=Mod-ans;
//cal second
for(i=1;i<=K+1;++i)ans=(ans+xishu[K][i]*((said[i]+said[i+1])%Mod))%Mod;
printf("%I64d\n",ans);
}
}

①考试时不要思考一道题超过半小时！
②做模的时候一定要仔细想加减乘除是否会爆，每一步都可能跪！
③一定要给自己出卡范围、卡上下界的特殊数据！

个人资料
等级：
访问量： 17万+
积分： 3684
排名： 1万+
最新评论