QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#651778 | #3083. Bit Operation | xyz123 | WA | 232ms | 55948kb | C++23 | 1.9kb | 2024-10-18 18:01:25 | 2024-10-18 18:01:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001];
long long dp[1000001],pw[1000001],fc[1000001];
char s[1000001];
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
int main()
{
// freopen("1.in","r",stdin);
srand((unsigned)(time(0)^(*new int)));
fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
fc[0]=1;
for(int i=1;i<=1000000;i++) fc[i]=fc[i-1]*pow_(2,mod-2)%mod*(2*i-1)%mod;
pw[0]=1;
for(int i=1;i<=1000000;i++) pw[i]=pw[i-1]*2%mod;
scanf("%lld",&a);
for(int i=1;i<=a;i++)
{
scanf("%lld",&d[i]);
}
for(int i=1;i<=a;i++)
{
dp[i]=fc[i-1]*fc[a-i]%mod*pow_(2,a-1)%mod*C(a-1,i-1)%mod;
}
for(int i=1;i<=a;i++)
{
if(d[i]) an=(an+dp[i])%mod;
}
// for(int i=2;i<=a;i++)
// {
// for(int j=1;j+i-1<=a;j++)
// {
// int r=j+i-1;
// for(int k=j;k<r;k++)
// {
// dp[j][r]=(dp[j][r]+(dp[j][k]*pw[r-k-1]%mod+dp[k+1][r]*pw[k-j]%mod)*pow_(r-j,mod-2))%mod;
// }
// }
// }
printf("%lld",(an%mod+mod)%mod);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 232ms
memory: 55948kb
input:
999993 1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 1...
output:
177804889
result:
wrong answer 1st lines differ - expected: '318158140', found: '177804889'