HDOJ 4876 ZCC loves cards
枚举组合,在不考虑连续的情况下推断能否够覆盖L...R,对随机数据是一个非常大的减枝.
通过检測的暴力计算一遍
ZCC loves cards
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1346 Accepted Submission(s): 335
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.
You can assume that all the test case generated randomly.
4 3 1
2 3 4 5
7Hint⊕ means xor
pid=4881" target="_blank" style="color:rgb(26,92,200); text-decoration:none">4881
pid=4880" target="_blank" style="color:rgb(26,92,200); text-decoration:none">4880
pid=4879" target="_blank" style="color:rgb(26,92,200); text-decoration:none">4879
pid=4878" target="_blank" style="color:rgb(26,92,200); text-decoration:none">4878
4877Statistic | pid=4876" style="color:rgb(26,92,200); text-decoration:none">Submit
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm> using namespace std; int n,k,m,a[30],save[30],have[30],R,L;
bool vis[3000],cx[200]; void ckMax(int num,int sum)
{
vis[sum]=true;
if(num==k) return ;
ckMax(num+1,sum^save[num]);
ckMax(num+1,sum);
} bool ck()
{
memset(vis,0,sizeof(vis));
ckMax(0,0);
for(int i=L;i<=R;i++)
{
if(vis[i]==false) return false;
}
return true;
} void CALU()
{
if (!ck()) return;
for(int i=0;i<k;i++)
have[i]=save[i];
do
{
memset(vis,0,sizeof(vis));
for(int i=0;i<k;i++)
{
int x=0;
for(int j=0;j<k;j++)
{
x^=have[(i+j)%k];
vis[x]=true;
}
}
for(int i=L;i<=L+k*k;i++)
{
if(vis[i]==false) break;
R=max(R,i);
}
}while(next_permutation(have,have+k-1));
} void dfs(int num,int id)
{
if(num==k)
{
CALU();
return ;
}
for(int i=id;i<n;i++)
{
save[num]=a[i];
dfs(num+1,i+1);
}
} int main()
{
while(scanf("%d%d%d",&n,&k,&L)!=EOF)
{
R=L-1;
for(int i=0;i<n;i++)
scanf("%d",a+i);
sort(a,a+n);
dfs(0,0);
if(R<L) printf("0\n");
else printf("%d\n",R);
}
return 0;
}
HDOJ 4876 ZCC loves cards的更多相关文章
- HDU 4876 ZCC loves cards(暴力剪枝)
HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...
- hdu 4876 ZCC loves cards(暴力)
题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...
- HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
GG,,,g艹 #include <cstdio> #include <iostream> #include <algorithm> #include <st ...
- 多校训练赛2 ZCC loves cards
ZCC loves cards Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- HDU4876:ZCC loves cards
Problem Description ZCC loves playing cards. He has n magical cards and each has a number on it. He ...
- HDU4876ZCC loves cards(多校题)
ZCC loves cards Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- hdu 5288 ZCC loves straight flush
传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K ...
- HDU 5228 ZCC loves straight flush( BestCoder Round #41)
题目链接:pid=5228">ZCC loves straight flush pid=5228">题面: pid=5228"> ZCC loves s ...
- 2014---多校训练2(ZCC Loves Codefires)
ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
随机推荐
- oracle一些笔记
1.字符串类型字段 区分大小写 where table_name = 'MIDDLE' 2.execute immediate '' bulk collect into v_xxx_tab 3.列别名 ...
- opencv(4)实现数据增加小工具
数据增加(data augmentation),作为一种深度学习中的常用手段,数据增加对模型的泛化性和准确性都有帮助.数据增加的具体使用方式一般有两种,一种是实时增加,比如在Caffe中加入数据扰动层 ...
- sql中多层循环示例(有游标)
在需求处理中,我们会遇到需要通过SQL多层循环来处理的问题.如:A表中有8条数据,B表中有10条数据,需要实现A表中的每1条数据对应B表中的10条数据,最后就有了80条数据,从而实现一对多的关系.那如 ...
- AARRR:数据运营模型
一.基础知识 产品经理 <增长黑客>数据分析基础 -- 获取(Acquisition)-- 激活(Activation)-- 留存(Retention)-- 收入(Revenue)-- ...
- ABP zero 3.2 发布
v3.2.0 (2017-03-07) Common Tenant based UI customizations (allow tenants to upload custom CSS and lo ...
- 从字节码角度分析Byte类型变量b++和++b
1. 下面是一到Java笔试题: public class Test2 { public void add(Byte b) { b = b++; } public void test() { Byte ...
- mycat 配置文件详解
server.xml 包含mycat的系统配置信息,它有两个标签,分别是user和system,掌握system标签的各项配置属性是mycat调优的关键. <?xml version=" ...
- jquery 分页 下拉框
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Gitlab-system-hooks
当创建或者删除,用户或者项目时,可能想收到一个通知.Gitlab支持这种类型的system hooks. 下面事件可以触发一个system webhook调用. Project created Pro ...
- Bootstrap进阶五:Web开发中很实用的交互效果积累
1.页面切换效果 我们已经在示例中罗列了一组动画,可以被应用到页面切换过程中,创造出很有趣的导航效果.  2.视差滚动(parallax-slider) 视差滚动(parallax-slider)已 ...