結果
問題 | No.1426 Got a Covered OR |
ユーザー |
![]() |
提出日時 | 2021-03-12 22:36:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,117 ms / 2,000 ms |
コード長 | 892 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 103,396 KB |
最終ジャッジ日時 | 2024-10-14 13:10:08 |
合計ジャッジ時間 | 6,418 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
n=int(input()) a=list(map(int,input().split())) prev=0 count=0 MOD=10**9+7 factorials=[1] temp=1 s=10**5 for i in range(1,s+1): temp=(temp*i)%MOD factorials.append(temp) inverses=[] for i in range(s+1): inverses.append(pow(factorials[i],MOD-2,MOD)) ans=1 for _ in range(n): count+=1 if a[_]!=-1: bitcount1=0 bitcount2=0 fail=0 for i in range(30): if prev&1<<i and not a[_]&1<<i: fail=1 elif prev&1<<i: bitcount2+=1 elif a[_]&1<<i: bitcount1+=1 if fail: print(0) exit() tmp0=0 for i in range(count+1): tmp=pow(-1,count-i) tmp=(tmp*factorials[count]*inverses[i]*inverses[count-i])%MOD tmp2=1 for j in range(bitcount1): tmp2=(tmp2*(pow(2,i,MOD)-1))%MOD tmp0=(tmp0+tmp*tmp2*pow(2,bitcount2*i,MOD))%MOD ans=(ans*tmp0)%MOD count=0 prev=a[_] print(ans)