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 ...
随机推荐
- Matlab读取txt中用空格分隔的数据文件到矩阵
转载...哪儿 忘记了 由于要做的项目中涉及到数据处理,初涉及到matlab.今天需要把一组只用空格分开的数据读取到一个三维矩阵,然后对这个矩阵进行处理. 思路是:首先用importdata读入txt ...
- 关于json中转义字符/正斜杠的问题。
1.首先有关转义字符 可以看百度百科: 先不管/是否需要转义,我们去json的官方网站去看看:http://www.json.org/ 可见有这个,那么意思是 json中 又规定建议了一下,意思是虽然 ...
- pytest mark中的skip,skipif, xfail
这些测试的过滤,或是对返回值的二重判断, 可以让测试过程更精准,测试结果更可控, 并可以更高层的应用测试脚本来保持批量化执行. import pytest import tasks from task ...
- GUC-11 线程池
import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java ...
- Tomcat --> Cannot create a server using the selected type
今天在eclipse想把之前的Tomcat 6删掉,重新配置一个,不料没有下一步 Cannot create a server using the selected type 这句话出现在窗口上面,应 ...
- React Native之网页组件WebView的使用与通信
在实际开发中,我们通常会嵌入一些html页面,官方为我们提供了一个非常好用的网页组件WebView,通过这个组件我们可以通过传入一个url或者是传入一段html 一. WebView的基本属性方法介绍 ...
- 一个UICollectionView自定义layout的实现
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @ ...
- 同步VDP时间
使用yast 进入蓝屏界面,修改system—date and time,取消hardware clock set to utc,时区设置为上海或者北京,然后sntp -r 时间服务器地址 敲击syn ...
- Python进阶篇:文件系统的操作
通过一个例子来熟悉文件的基本操作:创建文件,读取文件,修改文件,删除文件,重命名文件,判断文件是否存在 ''' 编写可供查询的员工信息表--学号 姓名 年龄 班级 1. 提供格式化查询接口 2. 允许 ...
- CF696B Puzzles 期望
显然可以树形$dp$ 令$f[i]$表示$i$号节点的期望时间戳 不妨设$fa$有$k$个子节点,对于$i$的子节点$u$,它是第$j(1 \leqslant j \leqslant k)$个被访问的 ...