結果
問題 | No.2300 Substring OR Sum |
ユーザー |
|
提出日時 | 2023-05-15 17:35:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 267 ms / 2,000 ms |
コード長 | 444 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 107,776 KB |
最終ジャッジ日時 | 2024-11-30 22:45:44 |
合計ジャッジ時間 | 4,745 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
n = int(input())a = list(map(int, input().split()))ans = 0for d in range(28):l = Nonest = []for i in range(n):if l is None:if (a[i] >> d) & 1 == 0:l = ielse:if (a[i] >> d) & 1 != 0:st.append((l, i - 1))l = Noneif not l is None:st.append((l, n - 1))cnt = n * (n + 1) // 2for l, r in st:cnt -= (r - l + 1) * (r - l + 2) // 2ans += (1 << d) * cntprint(ans)