QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#180435#7301. Even Three is OddCrysflyWA 1ms3448kbC++202.7kb2023-09-15 20:36:192023-09-15 20:36:20

Judging History

你现在查看的是最新测评结果

  • [2023-09-15 20:36:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3448kb
  • [2023-09-15 20:36:19]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ull unsigned long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}
 
#define mod 1000000007
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 2005
#define inf 0x3f3f3f3f

int n;
modint w[maxn],f[3][maxn],g[3][maxn];

void work()
{
	n=read();
	memset(f,0,sizeof f);
	For(i,1,n){
		w[i]=read();
		f[0][i]=w[i];
		f[1][i]=i*w[i];
		f[2][i]=i*f[1][i];
	}
	For(i,3,n-1){
		memset(g,0,sizeof g);
		g[2][1]=f[2][1];
		For(j,2,n)
			g[2][j]=g[2][j-1]+f[0][j]*(j-1)*(j-1)+f[1][j]*(j-1)+f[2][j];
		modint t=0;
		Rep(j,n,1){
			g[0][j]=f[1][j]+t;
			g[1][j]=f[2][j]+t*j;
			g[2][j]=g[2][j]+t*j*j;
			For(k,0,2)
				g[k][j]*=w[j];
			t+=f[0][j];
		}
		swap(f,g);
	}
	modint res=0;
	For(i,1,n)res+=f[0][i]*(i-1)*(i-1)+f[1][i]*(i-1)+f[2][i];
	cout<<res.x<<"\n";
}

signed main()
{
	while(cin>>n)work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3448kb

input:

3
1 2 3
4
1 1 1 1

output:

2
256

result:

wrong answer 1st numbers differ - expected: '72', found: '2'