当前位置:网站首页>Hdu4876zcc love cards (multi check questions)
Hdu4876zcc love cards (multi check questions)
2022-07-07 21:04:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
ZCC loves cards
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2362 Accepted Submission(s): 590
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 5Sample Output
7
Hint
⊕ means xor Author
Zhenhai middle school
Source
2014 Multi-University Training Contest 2
The question : to n Number . Choose from k Number , this k The number can be arranged randomly , Once the order is set, it cannot be changed , In this definite order . elect m(m<=k) The value obtained by the number XOR x, All in this order x Find a maximum value of R, Among these numbers, there is a continuous range L~R.
#include<stdio.h>
#include<string.h>
int n,k,L,ans[25];
int a[13],aa[13],R,flag[150];
int vist[10];
void find(int tk)
{
if(tk==k-1)
{
memset(flag,0,sizeof(flag));
for(int i=0;i<k-1;i++)
a[i+k]=a[i];
int maxa=0;
for(int i=0;i<k;i++)// Enumerate the XOR values of consecutive segments of a definite sequence
{
int x=a[i]; flag[x]=1; if(maxa<x)maxa=x;
for(int j=i+1;j-i+1<=k;j++)
{
x^=a[j]; flag[x]=1;if(maxa<x)maxa=x;
}
}
int r=0;
for(int i=L;i<=maxa;i++)// Find this maximum R, Make these numbers exist L~R The number of ranges exists .
if(flag[i]==0)break;
else r=i;
if(r>R)R=r;
return ;
}
tk++;
for(int i=0;i<k;i++)
if(vist[i]==0)
{
a[tk]=aa[i]; vist[i]=1; find(tk); vist[i]=0;
}
}
bool panduan()// Relax the conditions ( Random order ) infer
{
memset(flag,0,sizeof(flag));
int maxa=0;
for(int i=1;i<(1<<k);i++)
{
int x=0;
for(int j=0;(1<<j)<=i;j++)
if((1<<j)&i)x^=aa[j];
flag[x]=1;
if(maxa<x)maxa=x;
}
int r=0;
for(int i=L;i<=maxa;i++)
if(flag[i]==0)break;
else r=i;
return r>R;
}
void CNM(int tk,int i)
{
if(tk==k-1)
{
if(panduan())
find(-1);
return ;
}
tk++;
for(int j=i+1;j<n;j++)
{
aa[tk]=ans[j]; CNM(tk,j);
}
}
int main()
{
while(scanf("%d%d%d",&n,&k,&L)>0)
{
R=0; memset(vist,0,sizeof(vist));
for(int i=0;i<n;i++)
scanf("%d",&ans[i]);
CNM(-1,-1);
printf("%d\n",R);
}
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116456.html Link to the original text :https://javaforall.cn
边栏推荐
- Cantata9.0 | 全 新 功 能
- 使用枚举实现英文转盲文
- Is it safe to open an account of BOC shares in kainiu in 2022?
- 想杀死某个端口进程,但在服务列表中却找不到,可以之间通过命令行找到这个进程并杀死该进程,减少重启电脑和找到问题根源。
- AADL Inspector 故障树安全分析模块
- POJ 3140 Contestants Division「建议收藏」
- HDU4876ZCC loves cards(多校题)
- AADL inspector fault tree safety analysis module
- CodeSonar如何帮助无人机查找软件缺陷?
- 国家正规的股票交易app有哪些?使用安不安全
猜你喜欢

AADL inspector fault tree safety analysis module

C language helps you understand pointers from multiple perspectives (1. Character pointers 2. Array pointers and pointer arrays, array parameter passing and pointer parameter passing 3. Function point
Klocwork code static analysis tool

【OpenCV 例程200篇】223. 特征提取之多边形拟合(cv.approxPolyDP)

软件缺陷静态分析 CodeSonar 5.2 新版发布

Static analysis of software defects codesonar 5.2 release
![Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]](/img/af/61b384b1b6ba46aa1a6011f8a30085.png)
Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]

Implement secondary index with Gaussian redis

解决使用uni-app MediaError MediaError ErrorCode -5

万字总结数据存储,三大知识点
随机推荐
Intelligent software analysis platform embold
UVA 11080 – Place the Guards(二分图判定)
Nebula importer data import practice
OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
[UVALive 6663 Count the Regions] (dfs + 离散化)[通俗易懂]
Static analysis of software defects codesonar 5.2 release
Introduction to referer and referer policy
如何满足医疗设备对安全性和保密性的双重需求?
[matrix multiplication] [noi 2012] [cogs963] random number generator
Phoenix JDBC
Lex & yacc of Pisa proxy SQL parsing
恶魔奶爸 B2 突破语法,完成正统口语练习
[function recursion] do you know all five classic examples of simple recursion?
You want to kill a port process, but you can't find it in the service list. You can find this process and kill it through the command line to reduce restarting the computer and find the root cause of
[concept of network principle]
object-c编程tips-timer「建议收藏」
201215-03-19—cocos2dx内存管理–具体解释「建议收藏」
How does codesonar help UAVs find software defects?
Jetty:配置连接器[通俗易懂]
H3C s7000/s7500e/10500 series post stack BFD detection configuration method