当前位置:网站首页>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;
}
边栏推荐
- 【雕爷学编程】Arduino动手做(105)---压电陶瓷振动模块
- 1480. Dynamic sum of one-dimensional array
- 【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
- Appearance of LabVIEW error dialog box
- 如何使用postman实现简单的接口关联【增删改查】
- KMP match string
- Evolution of system architecture: differences and connections between SOA and microservice architecture
- [matlab] communication signal modulation general function interpolation function
- Supplement the JS of a video website to decrypt the video
- 724. 寻找数组的中心下标
猜你喜欢
What are the reasons for the frequent high CPU of ECS?
[Excel] 数据透视图
TCP state transition diagram
BUU-Crypto-[GXYCTF2019]CheckIn
BUU-Reverse-easyre
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
光模塊字母含義及參數簡稱大全
Electronic components mall and data manual download website summary
2022年R2移动式压力容器充装复训题库及答案
Analysis of classical pointer and array written test questions in C language
随机推荐
2022g2 power station boiler stoker special operation certificate examination question bank and answers
VB. Net GIF (making and disassembling - optimizing code, class library - 5)
XII Golang others
云原生架构实战案例及优化解决方案
ansys命令
[untitled]
企业级日志分析系统ELK(如果事与愿违那一定另有安排)
光模块字母含义及参数简称大全
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk
1480. Dynamic sum of one-dimensional array
19. Framebuffer application programming
1.1 history of Statistics
[matlab] matlab simulation modulation system - DSB system
[matlab] general function of communication signal modulation bandpass filter
Flask
LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
BUU-Reverse-easyre
BUU-Crypto-Cipher
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
2022年A特种设备相关管理(电梯)考试题模拟考试平台操作