博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU4876:ZCC loves cards
阅读量:6974 次
发布时间:2019-06-27

本文共 1674 字,大约阅读时间需要 5 分钟。

Problem Description
ZCC loves playing cards. He has n magical cards and each has a number on it. He wants to choose k cards and place them around in any order to form a circle. He can choose any several 
consecutive cards the number of which is m(1<=m<=k) to play a magic. The magic is simple that ZCC can get a number x=a1⊕a2...⊕am, which ai means the number on the ith card he chooses. He can play the magic infinite times, but 
once he begin to play the magic, he can’t change anything in the card circle including the order.
ZCC has a lucky number L. ZCC want to obtain the number L~R by using one card circle. And if he can get other numbers which aren’t in the range [L,R], it doesn’t matter. Help him to find the maximal R.
 

Input
The input contains several test cases.The first line in each case contains three integers n, k and L(k≤n≤20,1≤k≤6,1≤L≤100). The next line contains n numbers means the numbers on the n cards. The ith number a[i] satisfies 1≤a[i]≤100.
You can assume that all the test case generated randomly.
 

Output
For each test case, output the maximal number R. And if L can’t be obtained, output 0.
 

Sample Input
 
4 3 1 2 3 4 5
 

Sample Output
 
7
Hint
⊕ means xor
用全排列的方法来做。这我一開始还真没想到
#include 
#include
#include
using namespace std;int n,k,l,r;int vis[500],a[500],tem[500],s[500];void set(int len,int sum){ vis[sum] = 1; if(len == k) return ; set(len+1,sum^tem[len]); set(len+1,sum);}int check(){ memset(vis,0,sizeof(vis)); set(0,0); for(int i = l; i<=r; i++) if(!vis[i]) return 0; return 1;}void solve(){ if(!check()) return ; int i,j; for(i = 0; i

转载地址:http://gtesl.baihongyu.com/

你可能感兴趣的文章
Vue SPA 项目在 Amazon S3 部署小技巧
查看>>
数据段、数据报、数据包、帧的区别与联系
查看>>
如何迅速分析出系统CPU的瓶颈在哪里?
查看>>
Oracle推出轻量级Java微服务框架Helidon
查看>>
腾讯云小微激活硬件生态,携合作产品正式亮相
查看>>
记TensorFlow项目开源一周年
查看>>
「镁客·请讲」1058VR钱朱平:VR泛娱乐的时代未到,不妨从更细分的行业切入
查看>>
刷新本地的DNS缓存数据
查看>>
AI、量子计算引爆硬科技创新,雷鸣、王海峰、施尧耘等北大120周年论道信科最前沿...
查看>>
为什么物联网和区块链彼此依赖?
查看>>
安卓Textview的getLineCount返回0
查看>>
Windows 2008 R2 Administrator access denied解决办法
查看>>
Faker:Python的伪造数据生成器
查看>>
(桌面虚拟化最佳实践--呼叫中心系统优化之四)瘦终端优化项目与其他优化项目...
查看>>
自学社交的人工智能,会不会有一天取人类而代之?
查看>>
centos 6.5下安装fpm打包工具
查看>>
微信的视频如何找到文件并发送到电脑
查看>>
ionic react-native和native开发移动app到底那个好
查看>>
Grid_Oracle Grid Infrastructure概念介绍(概念)
查看>>
分布式全局锁
查看>>