QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#633160 | #3083. Bit Operation | ohwphil | TL | 0ms | 0kb | Python3 | 765b | 2024-10-12 14:40:17 | 2024-10-12 14:40:17 |
answer
FACTORIAL_LIMIT=2*10**6
MOD=119<<23|1
factorial=[1]*(FACTORIAL_LIMIT+1)
inv_factorial=[1]*(FACTORIAL_LIMIT+1)
for i in range(1,FACTORIAL_LIMIT+1):
factorial[i]=factorial[i-1]*i%MOD
inv_factorial[-1]=pow(factorial[-1],-1,MOD)
for i in range(FACTORIAL_LIMIT-1,0,-1):
inv_factorial[i]=inv_factorial[i+1]*(i+1)%MOD
N=int(input())
*arr,=map(int,input().split())
ans=0
def get_fun(x):
if x<=1:
return 1
ans=factorial[2*x-1]*pow(2,-x+1,MOD)*inv_factorial[x-1]%MOD
return ans
def nCr(n,r):
return factorial[n]*inv_factorial[r]*inv_factorial[n-r]%MOD
for i in range(N):
if arr[i]==1:
left_len=i
right_len=N-i-1
ans=(ans+get_fun(left_len)*get_fun(right_len)*nCr(N-1,left_len))%MOD
print(ans)
详细
Test #1:
score: 0
Time Limit Exceeded
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:
318158140