結果

問題 No.2300 Substring OR Sum
ユーザー nyyanyya
提出日時 2023-05-13 18:48:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 169,336 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-29 10:25:53
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) {

        int 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;
}
0