結果
| 問題 | No.2300 Substring OR Sum |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:41:16 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 2,000 ms |
| コード長 | 559 bytes |
| 記録 | |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 95,852 KB |
| 実行使用メモリ | 116,608 KB |
| 最終ジャッジ日時 | 2026-07-07 07:18:42 |
| 合計ジャッジ時間 | 4,592 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
n = int(input())
a = list(map(int, input().split()))
total_subarrays = n * (n + 1) // 2
result = 0
for k in range(28): # Process each bit from 0 to 27
count_zero = 0
current = 0
for num in a:
if (num & (1 << k)) == 0:
current += 1
else:
count_zero += current * (current + 1) // 2
current = 0
# Add the last segment of zeros after loop ends
count_zero += current * (current + 1) // 2
contribution = (total_subarrays - count_zero) * (1 << k)
result += contribution
print(result)
lam6er