当前位置:网站首页>Codeforces Round #648 (Div. 2) E.Maximum Subsequence Value
Codeforces Round #648 (Div. 2) E.Maximum Subsequence Value
2022-07-05 08:52:00 【Qizi K】
E.Maximum Subsequence Value
The question : to n Number , I want you to choose k Number , First turn them into 2 Base number , For binary number i position , If you choose k A few miles There are at least max(1,k−2) A digital Of binary i Is it 1, The answer is +2 Of i Power . Try to make ans Big .
tips:k>3 Certainly not better than k<=3 better .
Simple proof : If k<3, be max(1,k−2) == 1. here , The answer of the three numbers chosen is the answer of these three numbers “|” The value of the operation .( As long as this one has at least one 1, Then the answer can be increased ).
Choose these three numbers , If you choose another number (k==4), Then this number will not contribute to the original answer , Instead, it may reduce the answer .
【
If one of the original answers is 1:
A. This one of the original three numbers has >1 individual 1, Add the new number , This one remains the same ;
B. This one of the original three numbers has 1 individual 1, This new number is 1, This one remains the same ; otherwise , This one becomes 0 了 .
If one of the original answers is 0:
It means that the original three numbers are all 0, Add the new number , Even if the new number is 1, There is only a 1 individual 1, Less than max(1,k-2)==2, No contribution to the answer .
】
n<500, direct n3 Circulation is enough .
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll book[505], ans;
int main(){
scanf("%d",&n);
for(int i = 1; i <= n; ++i) scanf("%lld",&book[i]);
for(int i = 1; i <= n; ++i)
for(int j = i; j <= n; ++j)
for(int k = j; k <= n; ++k)
ans = max(ans, book[i] | book[j] | book[k]);
printf("%lld\n",ans);
return 0;
}
边栏推荐
- [daily training -- Tencent selected 50] 557 Reverse word III in string
- Business modeling of software model | overview
- Halcon shape_ trans
- golang 基础 —— golang 向 mysql 插入的时间数据和本地时间不一致
- Bit operation related operations
- Guess riddles (8)
- ABC#237 C
- kubeadm系列-00-overview
- Halcon clolor_ pieces. Hedv: classifier_ Color recognition
- [daiy4] jz32 print binary tree from top to bottom
猜你喜欢
猜谜语啦(4)
Halcon snap, get the area and position of coins
EA introduction notes
C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
[Niuke brush questions day4] jz55 depth of binary tree
Business modeling of software model | stakeholders
资源变现小程序添加折扣充值和折扣影票插件
Business modeling | process of software model
Hello everyone, welcome to my CSDN blog!
Guess riddles (10)
随机推荐
My university
Infix expression evaluation
整形的分类:short in long longlong
轮子1:QCustomPlot初始化模板
Ecmascript6 introduction and environment construction
319. 灯泡开关
Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
Guess riddles (3)
12. Dynamic link library, DLL
Guess riddles (2)
How can fresh students write resumes to attract HR and interviewers
TF coordinate transformation of common components of ros-9 ROS
Guess riddles (11)
One dimensional vector transpose point multiplication np dot
kubeadm系列-00-overview
It cold knowledge (updating ing~)
asp. Net (c)
MPSoC QSPI Flash 升级办法
Warning: retrying occurs during PIP installation
Meta标签详解