結果
| 問題 |
No.2300 Substring OR Sum
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-01-08 13:25:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 573 bytes |
| コンパイル時間 | 2,043 ms |
| コンパイル使用メモリ | 191,504 KB |
| 最終ジャッジ日時 | 2025-02-18 16:31:15 |
|
ジャッジサーバー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;
}
nonon