Resolve
We set \ (f [i] \) represents \ (K \) after a first number of operations at the \ (I \) positions plus the number of times,
The other number may be on,
The first \ (I \) number at the \ (J \) frequency position plus is the \ (F [J-I +. 1] \) .
Through to find the lawSample hand to playAfter it can be found,
\(f[i]=C_{i+k-2}^{i-1}\).
(But do not know why)
Finally, for each position on the line statistical contribution.
code:
#include <iostream>
#include <cstdio>
#include <cstring>
#define int long long
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;
inline int read(){
int sum=0,f=1;char ch=getchar();
while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
return f*sum;
}
const int N=5005;
int Mod=1000000007;
int n,K,a[N],f[N];
int jc[N]={1};
inline int fpow(int a,int b){
int ret=1;
while(b){
if(b&1) ret=ret*a%Mod;
a=a*a%Mod;b>>=1;
}
return ret;
}
inline int inv(int x){
return fpow(x,Mod-2);
}
inline int C(int n,int m){
int ret=1;
for(int i=n-m+1;i<=n;i++) ret=ret*i%Mod;
return ret*inv(jc[m])%Mod;
}
signed main(){
n=read();K=read();
for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%Mod;
for(int i=1;i<=n;i++) a[i]=read();
for(int i=1;i<=n;i++) f[i]=C(i+K-2,i-1);
for(int i=1;i<=n;i++){
int ret=0;
for(int j=1;j<=i;j++){
ret=(ret+a[j]*f[i-j+1]%Mod)%Mod;
}
printf("%lld\n",ret);
}
return 0;
}