結果
問題 | No.2300 Substring OR Sum |
ユーザー |
|
提出日時 | 2023-05-12 21:39:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 113 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 788 ms |
コンパイル使用メモリ | 66,612 KB |
最終ジャッジ日時 | 2025-02-12 22:18:33 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; int main() { ll n; cin >> n; int a[200005]; for(int i = 0; i < n; i++) { cin >> a[i]; } ll ans = 0; for(int c = 0; c < 28; c++) { ans += (n * (n + 1) / 2) << c; ll s = 0; for(int i = 0; i < n; i++) { if(!((a[i] >> c) & 1)) { s++; } else { s = 0; } ans -= s << c; } } cout << ans << endl; }