QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#633160#3083. Bit OperationohwphilTL 0ms0kbPython3765b2024-10-12 14:40:172024-10-12 14:40:17

Judging History

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

  • [2024-10-12 14:40:17]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [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

result: