結果
問題 | No.2300 Substring OR Sum |
ユーザー |
![]() |
提出日時 | 2023-05-12 22:41:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 1,847 ms |
コンパイル使用メモリ | 194,672 KB |
最終ジャッジ日時 | 2025-02-12 23:21:44 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; cin>>n; vector<ll> A(n); rep(i,n) cin>>A[i]; ll ans=0; ll tt=1; rep(i,28){ ll tmp=0; ll sum=n*(n+1)/2; rep(j,n){ if(!(A[j]&(1LL<<i))) { tmp++; } else{ sum-=(tmp+1)*tmp/2; tmp=0; } } sum-=(tmp+1)*tmp/2; ans+=sum*tt; tt*=2; } cout<<ans<<endl; return 0; }