Codeforces 578B. "Or" Game(思维题)
我们知道所有sigma(2^i){i<n}比2^n小,所以我们肯定是把这k次操作全部丢到一个数上看看能不能凑出二进制下一个更高位的1。
因为k最大只有10,我们可以求出每一个数乘以k次之后的值,然后记录一下前缀或和 后缀或和,枚举每一个数作为被乘数,前缀或当前数或后缀得出答案。
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=;
ll n, k, x;
ll a[maxn], b[maxn], qzh[maxn], hzh[maxn], ans;
void read(ll &k)
{
int f=; k=; char c=getchar();
while(c<'' || c>'') c=='-' && (f=-), c=getchar();
while(c<='' && c>='') k=k*+c-'', c=getchar();
k*=f;
}
int main()
{
read(n); read(k); read(x);
for(int i=;i<=n;i++)
{
read(a[i]); b[i]=a[i];
for(int j=;j<=k;j++) b[i]*=x;
qzh[i]=qzh[i-]|a[i];
}
for(int i=n;i;i--) hzh[i]=hzh[i+]|a[i];
for(int i=;i<=n;i++) ans=max(ans, qzh[i-]|b[i]|hzh[i+]);
printf("%I64d\n", ans);
}
Codeforces 578B. "Or" Game(思维题)的更多相关文章
- CF--思维练习-- CodeForces - 215C - Crosses(思维题)
ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...
- Codeforces 675C Money Transfers 思维题
原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...
- Codeforces 1090D - Similar Arrays - [思维题][构造题][2018-2019 Russia Open High School Programming Contest Problem D]
题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of ...
- codeforces 1140D(区间dp/思维题)
D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces 957 水位标记思维题
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...
- ACM思维题训练 Section A
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...
- codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...
- 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...
- C. Nice Garland Codeforces Round #535 (Div. 3) 思维题
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- CodeForces - 631C ——(思维题)
Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...
随机推荐
- php引用&使用笔记
引用与赋值是两个概念:引用是共用同一个内存地址,一个改变其他也会变,赋值是另外开辟内存空间,一个改变其他不会变 一个简单例子: $a=123; //$a开辟一个内存空间存储123 $b=&$a ...
- vue中的样式
一.使用class样式: CSS部分: <style> .green{ color:green; } .italic{ font-style:italic; } .thin{ ; } .a ...
- Elasticsearch.Net 异常:[match] query doesn't support multiple fields, found [field] and [query]
用Elasticsearch.Net检索数据,报异常: )); ElasticLowLevelClient client = new ElasticLowLevelClient(settings); ...
- c字符数组里的中文
char *p ="你abc"; strlen(p); //6 utf-8编码中
- phpquery 学习笔记
phpQuery是一个基于PHP的服务端开源项目,它可以让PHP开发人员轻松处理DOM文档内容,比如获取某新闻网站的头条信息.更有意思的是,它采用了jQuery的思想,你可以像使用jQuery一样处理 ...
- PSP Daily——团队项目Alpha发布
视频展示:优酷视频链接.文案如下 PSP Daily软件NABCD分析: 1) N (Need 需求) PSP Daily 解决了用户(软件工程课上学生)记录例行报告.写每周PSP表格和统计的需求.潜 ...
- 20170928-3 四则运算psp
1.本周psp: 2.本周进度条: 3.累计进度图(折线图): 4.psp饼状图:
- HDU 5428 The Factor 分解因式
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5428 The Factor Accepts: 101 Submissions: 811 Tim ...
- swift - tabBar图片设置的一些注意点
图片大小尺寸 刚刚开始接触的话,从美工那边拿来的图标大小一般都是偏大的,就像这样: 在此建议,tabBar的图标大小可以是32*32,个人感觉效果不错 图片的颜色问题 如上图所示,该图标的期望颜色(也 ...
- C++ Primer Plus学习:第十一章
运算符重载 使用方法: 在类的声明中定义重载运算符 datatype operator操作符(datatype); 定义:datatype classname:: operator操作符(dataty ...