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
7 Hint ⊕ 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 4877
pid=4876" style="color:rgb(26,92,200); text-decoration:none">Submit | Discuss | Note
- #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 ...
随机推荐
- FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑
FFmpeg_Tutorial FFmpeg工具和sdk库的使用demo 一.使用FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑 1.基本介绍 对于每一个从事音视频技术开发的工程师,想必没 ...
- windows 下的一些常用命令提示符
windows下dos命令窗口输入 netstat -ano即可查看端口使用情况, 如果要查看指定端口是否被占用 使用命令netstat -ano|findstr 端口号, 例如要查看8080端口号是 ...
- SQL2000数据库修改sa密码
开始——程序——Microsoft SQL Server——企业管理器 2 展开数据库Microsoft SQL Server—— SQL Server组——安全性——登录——双击sa 3 在常规内有 ...
- nginx + tomcat 集群记录
昨天晚写的时候已经下班了.时间紧迫.写的略简! 昨天说过.接到部署的任务之后.首先想到的是apache httpserver 毕竟pache.我们接触的比较多!然而部署之后遇到了很多问题.比如apac ...
- C++拾遗——重新开始
http://www.cnblogs.com/uniqueliu/category/307731.html
- loadrunner 脚本中文乱码
loadrunner 脚本中文乱码 1.新建脚本--->选择协议(Http)-->选项-->高级-->选择“支持字符集”并点选“UTF-8”: 2.在回放脚本之前:Vuser- ...
- nginx、php-fpm、swoole HTTP/TCP压测对比
本次测试是在win7下docker环境中进行压测,共创建一个nginx容器.一个php-fpm容器和一个swoole容器,客户端请求nginx服务器,nginx接收用户访问请求并转发给php-fpm, ...
- thinkphp getField()获取一列或一个数据
在开发中经常要获取一个数据的情况,thinkphp中有一个getField()方法可以解决这个问题. 获取一个数据 1 2 $user = M('demo'); $data = $user->g ...
- Bzoj4710 分特产(容斥原理+组合数)
题面 Bzoj 题解 考虑容斥原理,所有人都有特产的方案数等于: 至少零个人没有特产\(-\)至少一个人没有特产\(+\)至少两个人有特产\(-...\) 接着考虑其中一种情况怎么求(假设现在至少有\ ...
- JAVAEE——宜立方商城04:图片服务器FastDFS、富文本编辑器KindEditor、商品添加功能完成
1. 学习计划 1.图片上传 a) 图片服务器FastDFS b) 图片上传功能实现 2.富文本编辑器的使用KindEditor 3.商品添加功能完成 2. 图片服务器的安装 1.存储空间可扩展. 2 ...