結果
問題 | No.2300 Substring OR Sum |
ユーザー |
|
提出日時 | 2023-02-28 23:14:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 415 ms / 2,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 138 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 259,724 KB |
最終ジャッジ日時 | 2024-11-28 16:33:36 |
合計ジャッジ時間 | 5,303 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 import random n = ii() a = li() ans = (-1 + (1 << 30)) * (n * (n + 1) // 2) for bit in range(30): b = [] for v in a: if 1 & (v >> bit): b.append(1) else: b.append(0) cnt = 0 b.append(1) for v in b: if v != 0: ans -= (1 << bit) * cnt * (cnt + 1) // 2 cnt = 0 else: cnt += 1 print(ans)