結果
問題 | No.2300 Substring OR Sum |
ユーザー |
![]() |
提出日時 | 2023-05-13 18:49:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 1,754 ms |
コンパイル使用メモリ | 168,296 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 10:26:38 |
合計ジャッジ時間 | 3,590 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) typedef long long ll; int main(){ int n; cin >> n; vector<long long> a(n); rep(i,n) cin >> a[i]; ll ans = 0; rep(i,28) { ll sum = 0; int last = -1; rep(k,n) { if(a[k]&(1ll<<i)) { sum += (k-last)*(n-k); last = k; } } ans += (1ll<<i)*sum; } cout << ans << endl; return 0; }