当前位置:网站首页>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;
}
边栏推荐
- 猜谜语啦(2)
- Pearson correlation coefficient
- Guess riddles (142)
- Yolov4 target detection backbone
- [daily training -- Tencent selected 50] 557 Reverse word III in string
- 猜谜语啦(9)
- Explore the authentication mechanism of StarUML
- Basic number theory - factors
- MPSoC QSPI flash upgrade method
- Halcon clolor_ pieces. Hedv: classifier_ Color recognition
猜你喜欢
Redis实现高性能的全文搜索引擎---RediSearch
319. Bulb switch
Guess riddles (4)
Solutions of ordinary differential equations (2) examples
Programming implementation of ROS learning 5-client node
Wechat H5 official account to get openid climbing account
TypeScript手把手教程,简单易懂
AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解
Beautiful soup parsing and extracting data
ROS learning 4 custom message
随机推荐
Halcon Chinese character recognition
Mathematical modeling: factor analysis
Business modeling of software model | overview
C语言标准函数scanf不安全的原因
My experience from technology to product manager
猜谜语啦(11)
How can fresh students write resumes to attract HR and interviewers
Reasons for the insecurity of C language standard function scanf
[daiy4] copy of JZ35 complex linked list
Guess riddles (5)
Solutions of ordinary differential equations (2) examples
微信H5公众号获取openid爬坑记
Count of C # LINQ source code analysis
Program error record 1:valueerror: invalid literal for int() with base 10: '2.3‘
C#图像差异对比:图像相减(指针法、高速)
多元线性回归(sklearn法)
GEO数据库中搜索数据
使用arm Neon操作,提高内存拷贝速度
Oracle advanced (III) detailed explanation of data dictionary
Shift operation of complement