結果

問題 No.1426 Got a Covered OR
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-12 22:56:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,702 ms / 2,000 ms
コード長 1,098 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 110,192 KB
最終ジャッジ日時 2023-08-04 16:20:13
合計ジャッジ時間 6,350 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,292 KB
testcase_01 AC 65 ms
71,380 KB
testcase_02 AC 64 ms
71,176 KB
testcase_03 AC 66 ms
71,356 KB
testcase_04 AC 67 ms
71,376 KB
testcase_05 AC 64 ms
71,264 KB
testcase_06 AC 65 ms
71,288 KB
testcase_07 AC 65 ms
71,360 KB
testcase_08 AC 64 ms
71,328 KB
testcase_09 AC 63 ms
71,220 KB
testcase_10 AC 67 ms
71,372 KB
testcase_11 AC 67 ms
71,284 KB
testcase_12 AC 170 ms
91,888 KB
testcase_13 AC 272 ms
95,960 KB
testcase_14 AC 199 ms
90,216 KB
testcase_15 AC 155 ms
90,224 KB
testcase_16 AC 85 ms
76,560 KB
testcase_17 AC 102 ms
78,172 KB
testcase_18 AC 191 ms
99,168 KB
testcase_19 AC 186 ms
98,956 KB
testcase_20 AC 136 ms
82,760 KB
testcase_21 AC 138 ms
89,104 KB
testcase_22 AC 1,702 ms
108,568 KB
testcase_23 AC 235 ms
97,580 KB
testcase_24 AC 82 ms
89,440 KB
testcase_25 AC 197 ms
110,192 KB
testcase_26 AC 91 ms
90,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
B = list(map(int,input().split()))
mod = 10**9+7

num = 0
for b in B:
    if b != -1:
        if b|num != b:
            print(0)
            exit()
        num = b

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,max(40,n)+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def calc(x,all,le):
    ind = 1
    base = 0

    for i in range(x+1):
        count = 0
        mi = 1
        for j in range(le+1):
            count += mi*nCr(le,j,mod)*pow(2,(all-i)*(le-j),mod)
            count %= mod
            mi *= -1
        base += ind*nCr(x,i,mod)*count
        base %= mod
        ind *= -1

    return base


ans = 1
num = 0
now = 0
for b in B:
    num += 1
    if b == -1:
        continue
    x = b^now
    all = bin(b).count("1")
    c = 0
    for i in range(40):
        if x >> i & 1:
            c += 1
    ans *= calc(c,all,num)
    ans %= mod
    num = 0
    now = b
print(ans)
0