結果
問題 | No.2300 Substring OR Sum |
ユーザー |
![]() |
提出日時 | 2023-05-12 21:23:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 1,592 ms |
コンパイル使用メモリ | 168,388 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-28 17:09:39 |
合計ジャッジ時間 | 3,666 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } long long ans = 0; for (int i = 0; i < 28; i++){ ans += (long long) N * (N + 1) / 2 * (1 << i); int c = 0; for (int j = 0; j < N; j++){ if ((A[j] >> i & 1) == 0){ c++; ans -= (long long) c << i; } else { c = 0; } } } cout << ans << endl; }