当前位置:网站首页>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;
}
边栏推荐
- ping端口神器psping
- 2022年R2移动式压力容器充装复训题库及答案
- Solar insect killing system based on single chip microcomputer
- (4) Canal multi instance use
- Trie number dictionary tree
- Notepad++--显示相关的配置
- c语言经典指针和数组笔试题解析
- 2022 a special equipment related management (elevator) examination questions simulation examination platform operation
- Remote desktop client RDP
- Flask
猜你喜欢
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
KMP match string
小程序毕业设计---美食、菜谱小程序
2022G2电站锅炉司炉特种作业证考试题库及答案
PostgreSQL has officially surpassed mysql. Is this guy too strong!
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
Solar insect killing system based on single chip microcomputer
2022 t elevator repair operation certificate examination question bank and simulation examination
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
Just do it with your hands 7 - * project construction details 2 - hook configuration
随机推荐
Etcd database source code analysis - initialization overview
Flask
1.1 history of Statistics
空洞卷积、可变形卷积、可变形ROI Pooling
[matlab] general function of communication signal modulation Fourier transform
Just do it with your hands 7 - * project construction details 2 - hook configuration
724. 寻找数组的中心下标
Solar insect killing system based on single chip microcomputer
模拟小根堆
Integer type of C language
Unity is connected to the weather system
BUU-Real-[PHP]XXE
[matlab] matlab simulation modulation system - DSB system
Wechat applet +php realizes authorized login
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
Flink1.13 SQL basic syntax (I) DDL, DML
Trie数-字典树
Thinkphp6.0 middleware with limited access frequency think throttle
VB.net GIF(制作、拆解——优化代码,类库——5)
[paper summary] zero shot semantic segmentation