当前位置:网站首页>Arc135 C (the proof is not very clear)
Arc135 C (the proof is not very clear)
2022-07-04 05:35:00 【Find a derivative first】
subject
The question : Given array a, You can perform any operation . Select any number in the array a[i], Make the whole array execute ^a[i]. After the operation, the array a The largest sum of .
Ideas : It can be proved that the operation is not performed and the operation is performed 1 Times include all cases .
Time complexity : O(nlogn)
Code :
// Problem: C - XOR to All
// Contest: AtCoder - AtCoder Regular Contest 135
// URL: https://atcoder.jp/contests/arc135/tasks/arc135_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<complex>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<list>
#include<set>
#include<queue>
#include<stack>
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i<=b;++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define p_ priority_queue
// round() rounding ceil() Rounding up floor() Rounding down
// lower_bound(a.begin(),a.end(),tmp,greater<ll>()) First less than or equal to
// #define int long long //QAQ
using namespace std;
typedef complex<double> CP;
typedef pair<int,int> PII;
typedef long long ll;
// typedef __int128 it;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll inf = 1e18;
const int N = 3e5+10;
const int M = 1e6+10;
const int mod = 1e9+7;
const double eps = 1e-6;
inline int lowbit(int x){
return x&(-x);}
template<typename T>void write(T x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)
{
write(x/10);
}
putchar(x%10+'0');
}
template<typename T> void read(T &x)
{
x = 0;char ch = getchar();ll f = 1;
while(!isdigit(ch)){
if(ch == '-')f*=-1;ch=getchar();}
while(isdigit(ch)){
x = x*10+ch-48;ch=getchar();}x*=f;
}
int n,m,k,T;
int a[N];
int cnt[N][2]; //0、1
ll ans = 0;
void solve()
{
read(n);
for(int i=1;i<=n;++i)
{
read(a[i]);
ans += a[i];
for(int j=0;j<30;++j)
{
if(a[i]>>j&1) cnt[j][1]++;
else cnt[j][0]++;
}
}
for(int i=1;i<=n;++i)
{
ll res = 0;
for(int j=0;j<30;++j)
{
if(a[i]>>j&1) res += 1ll*cnt[j][0]*(1<<j);
else res += 1ll*cnt[j][1]*(1<<j);
}
ans = max(ans,res);
}
write(ans);
}
signed main(void)
{
T = 1;
// OldTomato; cin>>T;
// read(T);
while(T--)
{
solve();
}
return 0;
}
边栏推荐
- Google Chrome browser will support the function of selecting text translation
- VB. Net GIF (making and disassembling - optimizing code, class library - 5)
- Notepad++--显示相关的配置
- XII Golang others
- 十二. golang其他
- 2022 question bank and answers for safety management personnel of hazardous chemical business units
- Etcd database source code analysis - initialization overview
- Redis realizes ranking function
- Remote desktop client RDP
- 2022 R2 mobile pressure vessel filling retraining question bank and answers
猜你喜欢

Simulated small root pile
![[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB](/img/8e/90d08d22a2d340242be2357f662ea4.jpg)
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB

光模塊字母含義及參數簡稱大全

Trie number dictionary tree

Trie数-字典树

补某视频网站的js,进行视频解密

Canoe panel learning video

Penetration tool - sqlmap

Halcon图片标定,使得后续图片处理过后变成与模板图片一样

Void convolution, deformable convolution, deformable ROI pooling
随机推荐
RSA加密应用常见缺陷的原理与实践
VB. Net calls ffmpeg to simply process video (class Library-6)
[paper summary] zero shot semantic segmentation
[matlab] matlab simulation modulation system FM system
Character types of C language
Li Kou's 300th weekly match
Introduction To AMBA 简单理解
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
fastjson
[matlab] matlab simulation modulation system - VSB system
Flask
VB.net 调用FFmpeg简单处理视频(类库——6)
[matlab] matlab simulation of modulation system - power spectrum and coherent demodulation of AM modulated signal
Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
Unity2d -- character moves and turns
Trie数-字典树
2022年R2移动式压力容器充装复训题库及答案
Canoe panel learning video
KMP匹配字符串
KMP match string