結果
問題 | No.2300 Substring OR Sum |
ユーザー |
![]() |
提出日時 | 2024-01-08 13:25:38 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 573 bytes |
コンパイル時間 | 2,381 ms |
コンパイル使用メモリ | 200,164 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-27 19:36:06 |
合計ジャッジ時間 | 4,424 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; int N; long A[2<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; for(int i=0;i<N;i++)cin>>A[i]; long ans=0; for(int bit=0;bit<30;bit++) { long len=0,sum=0; for(int i=0;i<N;i++) { if(A[i]&(1<<bit)) { sum+=len*(len+1)/2; len=0; } else len++; } sum+=len*(len+1)/2; sum=(long)N*(N+1)/2-sum; ans+=sum*(1L<<bit); } cout << ans << endl; }