当前位置:网站首页>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;
}
边栏推荐
- 1480. 一维数组的动态和
- C language simple student management system (including source code)
- FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
- IP时代来临,电竞酒店如何借好游戏的“东风”?
- BUU-Real-[PHP]XXE
- Introduction To AMBA 简单理解
- [matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (cosine roll off forming pulse)
- 总线的基本概念
- left_and_right_net正常版本
- Just do it with your hands 7 - * project construction details 2 - hook configuration
猜你喜欢
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

拓扑排序和关键路径的图形化显示

2022 question bank and answers for safety management personnel of hazardous chemical business units

2022年T电梯修理操作证考试题库及模拟考试

The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat

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

Google Chrome browser will support the function of selecting text translation

VB.net GIF(制作、拆解——优化代码,类库——5)

19. Framebuffer application programming
![BUU-Crypto-[HDCTF2019]basic rsa](/img/d0/8e451dabb2a6897f6680220d16d04d.jpg)
BUU-Crypto-[HDCTF2019]basic rsa
随机推荐
[paper summary] zero shot semantic segmentation
[paper summary] zero shot semantic segmentation
Character types of C language
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
tutle时钟改进版
Thinkphp6.0 middleware with limited access frequency think throttle
Evolution of system architecture: differences and connections between SOA and microservice architecture
SQL injection - injection based on MSSQL (SQL Server)
Etcd database source code analysis - initialization overview
Trie number dictionary tree
transformer坑了多少算力
2022 R2 mobile pressure vessel filling retraining question bank and answers
总线的基本概念
1480. Dynamic sum of one-dimensional array
[matlab] matlab simulation - narrow band Gaussian white noise
光模塊字母含義及參數簡稱大全
企业级日志分析系统ELK(如果事与愿违那一定另有安排)
fastjson
Remote desktop client RDP
TCP state transition diagram