結果
| 問題 | No.1426 Got a Covered OR |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-01-05 01:04:42 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 2,000 ms |
| コード長 | 1,210 bytes |
| 記録 | |
| コンパイル時間 | 288 ms |
| コンパイル使用メモリ | 82,492 KB |
| 実行使用メモリ | 118,164 KB |
| 最終ジャッジ日時 | 2026-01-05 01:04:46 |
| 合計ジャッジ時間 | 4,359 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
import sys
input = sys.stdin.readline
mod=10**9+7
FACT=[1]
for i in range(1,2*10**5+1):
FACT.append(FACT[-1]*i%mod)
FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
FACT_INV.append(FACT_INV[-1]*i%mod)
FACT_INV.reverse()
def Combi(a,b):
if 0<=b<=a:
return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
else:
return 0
N=int(input())
B=list(map(int,input().split()))
ANS=1
now=0
minus=0
for i in range(N):
if B[i]==-1:
minus+=1
else:
x=B[i]
if x & now == now:
k=now.bit_count()
l=x.bit_count()
score=0
rest=l-k
#print("!",rest)
for j in range(rest+1):
if j%2==0:
score=score+Combi(rest,j)*pow(pow(2,l-j)-1,minus+1,mod)
else:
score=score-Combi(rest,j)*pow(pow(2,l-j)-1,minus+1,mod)
#print(score)
score%=mod
#print("?",score)
minus=0
now=x
ANS=ANS*score%mod
else:
print(0)
exit()
k=now.bit_count()
ANS=ANS*pow(pow(2,k)-1,minus,mod)%mod
print(ANS)
titia