当前位置:网站首页>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;
}
边栏推荐
- Flask
- Basic concept of bus
- Penetration tool - sqlmap
- BUU-Real-[PHP]XXE
- Evolution of system architecture: differences and connections between SOA and microservice architecture
- Automated testing selenium foundation -- webdriverapi
- 简易零钱通
- Canoe panel learning video
- Appearance of LabVIEW error dialog box
- Introduction To AMBA 简单理解
猜你喜欢
Electronic components mall and data manual download website summary
How to use postman to realize simple interface Association [add, delete, modify and query]
Void convolution, deformable convolution, deformable ROI pooling
Introduction To AMBA 简单理解
Character types of C language
[paper summary] zero shot semantic segmentation
Graduation design of small programs -- small programs of food and recipes
TCP state transition diagram
小程序毕业设计---美食、菜谱小程序
Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
随机推荐
KMP匹配字符串
[matlab] communication signal modulation general function - low pass filter
[matlab] matlab simulation of modulation system - power spectrum and coherent demodulation of AM modulated signal
LM small programmable controller software (based on CoDeSys) note XXI: error 3703
724. Find the central subscript of the array
拓扑排序和关键路径的图形化显示
Leetcode 184 Employees with the highest wages in the Department (July 3, 2022)
KMP match string
SQL performance optimization skills
Li Kou's 300th weekly match
Yyds dry goods inventory TCP & UDP
2022 R2 mobile pressure vessel filling retraining question bank and answers
19.Frambuffer应用编程
[QT] timer
Trie数-字典树
Evolution of system architecture: differences and connections between SOA and microservice architecture
C # character similarity comparison general class
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
简易零钱通
Flink1.13 SQL basic syntax (I) DDL, DML