我们知道所有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(思维题)的更多相关文章

  1. CF--思维练习-- CodeForces - 215C - Crosses(思维题)

    ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...

  2. Codeforces 675C Money Transfers 思维题

    原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...

  3. 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 ...

  4. codeforces 1140D(区间dp/思维题)

    D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. Codeforces 957 水位标记思维题

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  6. ACM思维题训练 Section A

    题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...

  7. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  8. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  9. 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 ...

  10. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

随机推荐

  1. 安装Vue.js的方法有三种

    1 使用独立的版本 在Vue.js官网上直接下载,在script标签里引用. 2 使用CND方法(不推荐) 3 NMP 方法 在用Vue.js构建大型应用的时候推荐使用NMP安装方法,NMP能很好的和 ...

  2. selenium自动化之稳定版本环境介绍

    大家都知道,目前selenium版本已经升级到3.0了,selenium3只是在selenium2的基础上做了一些调整,最明显的区别就是 selenium2对Firefox的支持最高只支持46及以下版 ...

  3. CF刷题-Codeforces Round #481-D. Almost Arithmetic Progression

    题目链接:https://codeforces.com/contest/978/problem/D 题解: 题目的大意就是:这组序列能否组成等差数列?一旦构成等差数列,等差数列的公差必定确定,而且,对 ...

  4. Phaser3让超级玛丽实现轻跳、高跳及加上对应的跳跃声音

      mario jumper 在线测试地址:http://www.ifiero.com/uploads/phaserjs3/jumper/ 空格键:轻按:跳低 ,长按:跳高键盘:--> 向右 , ...

  5. 获取Java线程返回值的几种方式

    在实际开发过程中,我们有时候会遇到主线程调用子线程,要等待子线程返回的结果来进行下一步动作的业务. 那么怎么获取子线程返回的值呢,我这里总结了三种方式: 主线程等待. Join方法等待. 实现Call ...

  6. Centos下安装并设置nginx开机自启动

    一.在centos环境下安装下载并安装nginx,由于nginx需要依赖一些环境才能安装,主要依赖g++.gcc.openssl-devel.pcre-devel和zlib-devel这些环境,首先得 ...

  7. Google Chrome插件分享

    前言 浏览器是大家日常使用最多的工具之一,对于程序员来说,Google Chrome浏览器当然是大家优选的最爱之一.面对Chrome丰富的插件真的是爱不释手,如何把自己的Chrome调教成自己心仪的样 ...

  8. Linux建立互信关系(ssh公钥登录)

    Linux有多种登录方式,比如telnet.ssh.支持ssh登录方式:口令登录和公钥登录 ssh登录方式:ssh [-l login_name] [-p port] [user@]hostname ...

  9. ES数据备份到HDFS

    1.准备好HDFS(这里我是本机测试) 2.es 安装repository-hdfs插件 (如es为多节点需在每个节点都安装插件) elasticsearch-plugin install repos ...

  10. jpa的@Query中"?"占位符的使用小坑

    今天使用@Query自定义查询语句,出现了一个错误: java.lang.IllegalArgumentException: Parameter with that position [1] did ...