You are given n numbers a1, a2, …, an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make as large as possible, where denotes the bitwise OR.

Find the maximum possible value of after performing at most k operations optimally.

Input
The first line contains three integers n, k and x (1 ≤ n ≤ 200 000, 1 ≤ k ≤ 10, 2 ≤ x ≤ 8).

The second line contains n integers a1, a2, …, an (0 ≤ ai ≤ 109).

Output
Output the maximum value of a bitwise OR of sequence elements after performing operations.

Example
Input
3 1 2
1 1 1
Output
3
Input
4 2 3
1 2 4 8
Output
79
Note
For the first sample, any possible choice of doing one operation will result the same three numbers 1, 1, 2 so the result is .

For the second sample if we multiply 8 by 3 two times we’ll get 72. In this case the numbers will become 1, 2, 4, 72 so the OR value will be 79 and is the largest possible result.

这个东西肯定乘在一个上面
位数越多越好

因为前面这一大堆的合等于高一位的-1
所以不用犹豫

然后前缀后缀一处理就可以了

#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
ll tu[200001],qz[200002],hz[200002];
int main()
{ll daan = 0;int n, k, x;cin >> n >> k >> x;for (int a = 1; a <= n; a++)scanf("%lld", &tu[a]);for (int a = 1; a <= n; a++)qz[a] = tu[a] | qz[a - 1];for (int a = n; a >= 1; a--)hz[a] = tu[a] | hz[a + 1];ll qw = 1;for (int a = 1; a <= k; a++)qw *= x;for (int a = 1; a <= n; a++)daan = max(daan, qz[a - 1] | hz[a + 1] | tu[a] * qw);cout << daan;
}

codeforces 579D(35/600)相关推荐

  1. 【21.37%】【codeforces 579D】Or Game

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 第十六届全国大学生智能汽车竞赛(西部赛区) 竞速组成绩及获奖情况公示

    第十六届全国大学生智能汽车竞赛(西部赛区) 竞速组成绩及获奖情况公示 §01 成绩与奖项 第十六届全国大学生智能汽车竞赛(西部赛区)比赛于2021年7月26日-29日在重庆大学举行.现将竞速组竞赛成绩 ...

  3. 2006年软件500强

    引自:http://hot.techcn.com.cn/1109soft500/index.html   世界软件500强历年排名 | 专题 | 科技中国首页| 中国TNT论坛 从整体上看,2006的 ...

  4. cf600 E. Lomsat gelral

    cf600 E. Lomsat gelral 题意: 给出一个树,求出每个节点的子树中出现次数最多的颜色的编号和 题解: 树上启发式合并 树上启发式合并讲解 其实就是:递归轻儿子,消除影响,递归重儿子 ...

  5. 0505.Net基础班第十三天(面向对象多态)

    1.c#中的访问修饰符 public :公开的公共的 private:私有的,只能在当前类的内部访问 protected:受保护的,只能在当前类的内部以及该类的子类中访问. internal:只能在当 ...

  6. 【云原生 | Kubernetes 系列】--Envoy熔断

    1. 区域感知路由 通常,始发集群和上游集群属于不同区域的部署中,Envoy执行区域感知路由 区域感知路由(zone aware routing)用于尽可能地向上游集群中的本地区域发送流量,并大致确保 ...

  7. 新浪财经沪深300指数期权和商品期权行情接口

    新浪财经的沪深300指数期权接口和商品期权接口是一样的. 期权T行报价http://stock.finance.sina.com.cn/futures/api/openapi.php/OptionSe ...

  8. 阿里云分析型数据库MySQL版(AnalyticDB)测试初体验

    其实是测试半遂体验. 这阵子对OLAP数据库产生了兴趣,先是简单测试了ClickHouse,性能的确不错,不过它在稳定&可靠性,整体生态&周边配套方面还有待加强,我会持续保持关注. 3 ...

  9. 在网上购物竟然也能和Python扯上关系!电脑上用自己写的程序购物?别说,QT实现还真挺简单(Python如何利用QT制作电脑的手机版拼多多)

    拼多多现在也是越来越火了,但是不知道大家有没有发现,拼多多似乎一直不能通过网页进行访问.淘宝,京东都有微信客户端,那么怎么拼多多就没有呢?带着这个疑问,我特地去手机爬取了一下拼多多的客户端.(其实也不 ...

最新文章

  1. 数据中心网络性能:新应用下的新需求
  2. DigSci科学数据挖掘大赛:如何在3天内拿下DigSci亚军
  3. structs2多文件上传
  4. AGC 022 B - GCD Sequence
  5. 跟我一起学Vim补全神级插件--YouCompleteMe
  6. 基于Python开发用于钞票认证的神经网络
  7. 打印机添加或者设置流程
  8. ffmpeg系列之两种视频解码方式
  9. ubuntu linux 软件安装位置,ubuntu查看软件安装位置
  10. 手机h5像素_移动端H5页面的设计稿尺寸大小规范
  11. Java笔记 - 黑马程序员_08(Lambda表达式,接口组成更新,方法引用,类加载器,反射)
  12. RationalDMIS 7.1建立工件坐标系的过程:必须尊守321法则
  13. 虚拟机安装centos7
  14. hive 启动报错java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%..
  15. IntelliJ IDEA创建java项目
  16. php gbk转utf8
  17. 详解Vue中使用scope进行样式隔离
  18. C++学习(四八二)zlib的inflate
  19. 布局文件:报警告 This inspection highlights unknown XML attributes in Android resource files and Andro...
  20. Javascript JS 网页分享到QQ空间QQ,java实现qq分享,url带参数的方法

热门文章

  1. GITHUB实用有趣工具推荐
  2. 计算机科学与技术500分左右的大学,全国所有500分左右的211大学
  3. Java毕设项目:房屋租赁管理系统(java+SSM+Maven+Mysql+Jsp)
  4. 江南百景图过Root检测
  5. Dijkstra 路径规划算法原理详解及 Python 代码实现
  6. 【计算机毕业设计】133在线课程管理系统
  7. NC 工具的使用教程
  8. Win8系统flash无法播放视频怎么办?
  9. Oracle时间函数 to_char()及常用时间格式
  10. python计算银行余额_Python 小案例实战 —— 简易银行存取款查询系统