感觉非常显然,就是求
[x4](1+a1x)(1+a2x)…(1+anx)
一直不对,我还要跟这个随机跳题跳出来的斗吗
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<=(k);i++)
#define per(i,j,k) for(int i=j;i>=(k);i--)
#define all(x) x.begin(),x.end()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define maxn 2097152
typedef vector<int> poly;
#define rg register
typedef long long i64;
const int p=1e9+7;
template<class _Tp,class _tp>void add(_Tp&x,const _tp& y){((x+=y)>=p)&&(x-=p);}template<class _Tp,class _tp>_Tp Add(_Tp x,const _tp y){add(x,y);return x;}
template<class _Tp,class _tp>void sub(_Tp&x,const _tp&y){((x-=y)<0)&&(x+=p);}template<class _Tp,class _tp>_Tp Sub(_Tp x,const _tp y){sub(x,y);return x;}
template<class _Tp,class _tp>void mul(_Tp&x,const _tp&y){x=1ll*x*y%p;}template<class _Tp,class _tp>_Tp Mul(const _Tp x,const _tp y){return 1ll*x*y%p;}
template<class _Tp,class _tp>_Tp ksm(_Tp a,_tp b){_Tp ans(1);for(;b;b>>=1,mul(a,a))if(b&1)mul(ans,a);return ans;}
template<class _Tp>_Tp div2(_Tp a){if(a&1)a+=p;return a>>1;}
int n;
poly f[100010];
poly mtt(poly a,poly b){
poly c(a.size()+b.size()-1);
rep(i,0,a.size()-1)rep(j,0,b.size()-1)
add(c[i+j],Mul(a[i],b[j]));
c.resize(5);
return c;
}
poly dfs(int l,int r){
int mid=(l+r)>>1;
if(l==r)return f[l];
return mtt(dfs(l,mid),dfs(mid+1,r));
}
void solve(){
rep(i,1,n){
int x;
scanf("%d",&x);
f[i]={1,x};
}
if(n<4)puts("0");
else printf("%d\n",dfs(1,n)[4]);
}
signed main(){
while(scanf("%d",&n)!=EOF){
solve();
}
}