#include #define rep(i,n) for(int i=0;i struct Matrix{ vector> mat; Matrix(const int h,const int w): mat(h,vector(w,0)) {} Matrix(const vector> &G): mat(G) {} int height() const{ return mat.size(); } int width() const{ return mat[0].size(); } // 添字 const vector &operator[](int i) const{ assert(0<=i&&i<(int)mat.size()); return mat[i]; } vector &operator[](int i){ assert(0<=i&&i<(int)mat.size()); return mat[i]; } // 単位元 Matrix I(int n,T x){ Matrix ret(n,n); for(int i=0;i> ret(h,vector(_w,0)); for(int y=0;y0){ if(k&1) ret*=(*this); (*this)*=(*this); k>>=1ll; } (*this)=ret; return (*this); } void debug(){ int h=height(),w=width(); for(int y=0;y struct ModInt{ int64 x; ModInt():x(0){} ModInt(int64 x): x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD) {} // 負号 ModInt operator -() const{ return ModInt(-x); } // 加算 ModInt &operator +=(const ModInt &rhs){ x+=rhs.x; if(x>=MOD) x-=MOD; return (*this); } ModInt operator +(const ModInt &rhs) const{ return ModInt(*this)+=rhs; } // 減算 ModInt &operator -=(const ModInt &rhs){ x+=MOD-rhs.x; if(x>=MOD) x-=MOD; return (*this); } ModInt operator -(const ModInt &rhs) const{ return ModInt(*this)-=rhs; } // 乗算 ModInt &operator *=(const ModInt &rhs){ x*=rhs.x; if(x>=MOD) x%=MOD; return (*this); } ModInt operator *(const ModInt &rhs) const{ return ModInt(*this)*=rhs; } // 除算 ModInt &operator /=(const ModInt &rhs){ (*this)*=rhs.inverse(); return (*this); } ModInt operator /(const ModInt &rhs) const{ return ModInt(*this)/=rhs; } // 等号 bool operator ==(const ModInt &rhs){ return x==rhs.x; } bool operator !=(const ModInt &rhs){ return x!=rhs.x; } // 累乗 ModInt pow(int64 n){ int64 tmp=x; x=1; while(n>0){ if(n&1) x=x*tmp%MOD; tmp=tmp*tmp%MOD; n>>=1ll; } return (*this); } // 逆元 ModInt inverse(){ int64 a=x,b=MOD,s=1,t=0; while(b>0){ int64 u=b/a; b-=u*a; t-=u*s; swap(a,b); swap(s,t); } return ModInt(s); } // 入出力 friend istream &operator >>(istream &lhs,ModInt &rhs){ int64 x; lhs>>x; rhs=ModInt(x); return lhs; } friend ostream &operator <<(ostream &lhs,const ModInt &rhs){ return lhs<; long long n,k; cin>>n>>k; // はずれ if(k<=n){ mint f,sum=0; for(int i=1;i<=k;i++){ cin>>f; sum+=f; } cout<30){ mint f[k+1],s[k+1]; for(int i=1;i<=n;i++){ cin>>f[i]; s[i]=f[i]+s[i-1]; } for(int i=n+1;i<=k;i++){ f[i]=s[i-1]-s[i-n-1]; s[i]=f[i]+s[i-1]; } cout<>f[i]; s[i]=f[i]+s[i-1]; } Matrix mat(n+1,n+1); mat[0][0]=2; mat[0][n]=-1; for(int y=1;y