HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
GG,,,g艹
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
vector<int>G[21][7];//G[i][j] 表示n=i k=j的情况下 二进制的状态
int n, k, l;
int a[21], d[6], val[6];
int vis[150], tim;
int work(int x){
int i = 0, j = 0;
while(x) {
if(x&1) d[i++] = j;//a[j]
j++;
x>>=1;
}
int ans = 0;
do
{
memset(val, 0, sizeof val);
tim ++;
int st = 0;
for(int num = 0; num < k; num++) {
i = st; j = 0;
while(1) {
val[j] ^= a[d[i]];
vis[val[j]] = tim;
i++; j++;if(i>=k)i=0;
if(i==st)break;
}
st++;
}
for(i = l; ; i++)
if(vis[i]!=tim)
{
ans = max(ans, (i-1)>=l? (i-1):0);
break;
}
} while (next_permutation(d + 1, d + k));
return ans;
}
void dfs(int dep, int cnt, int num) {
if (dep > 20 || cnt > 6) return ;
G[dep][cnt].push_back(num);
dfs(dep + 1, cnt + 1, num | (1 << dep));
dfs(dep + 1, cnt, num);
} struct Node {
int cnt, idx;
bool operator < (const Node &rhs) const {
return cnt > rhs.cnt;
}
}; Node qq[24];
int b[24]; int cmp(int a, int b) {
return a > b;
} int main(){
int i, j;
for(i = 1; i <= 20; i++)
for(j = 1; j <= 6; j++) G[i][j].clear();
dfs(0, 0, 0);
tim = 100;
while(~scanf("%d %d %d",&n, &k, &l)) {
for(i = 0; i < n; i++)scanf("%d",&a[i]); int ans = 0, siz = (int)G[n][k].size();
if (siz <= 12000) {
for (int i = 0; i < siz; ++i) {
int cur = G[n][k][i];
ans = max(ans, work(cur));
}
} else if (siz <= 24001) {
for (int i = 1; i < siz; i += 2) {
int cur = G[n][k][i];
ans = max(ans, work(cur));
}
} else {
for (int i = 0; i < siz; i += 3) {
int cur = G[n][k][i];
ans = max(ans, work(cur));
}
} printf("%d\n",ans);
}
return 0;
}
HDU 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)张连续的牌,取牌上值 ...
- HDOJ 4876 ZCC loves cards
枚举组合,在不考虑连续的情况下推断能否够覆盖L...R,对随机数据是一个非常大的减枝. 通过检測的暴力计算一遍 ZCC loves cards Time Limit: 4000/2000 MS (Ja ...
- hdu 4873 ZCC Loves Intersection(大数+概率)
pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...
- 多校训练赛2 ZCC loves cards
ZCC loves cards Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- HDU 4873 ZCC Loves Intersection(可能性)
HDU 4873 ZCC Loves Intersection pid=4873" target="_blank" style="">题目链接 ...
- hdu 4882 ZCC Loves Codefires(数学题+贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...
- 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 ...
随机推荐
- 基于visual Studio2013解决C语言竞赛题之0417四倍数
题目 解决代码及点评 这道题目还是考察循环,通过循环遍历1234~9876,然后将每个数都用算法判断其是否符合条件#include <stdio.h> #include ...
- 基于visual Studio2013解决C语言竞赛题之0603打印素数
题目
- Hdu 1404 Digital Deletions
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1404 刚开始想采取找规律的方法解题,可以没有发现规律.无奈,只好采用求PN点的方法. 我们假 ...
- Android平台下使用lua调用Java代码经验总结
动态语言以其执行的灵活性,可配置性.方便调试能够为开发带来极大的方便.假设用好了.能够极大的提高开发的效率. 怪不得像游戏开发这样复杂的软件开发里没有不集成脚本语言的. 当中,lua以其小巧,灵活.方 ...
- 10个SQL注入工具(转载)
众所周知,SQL注入攻击是最为常见的Web应用程序攻击技术.同时SQL注入攻击所带来的安全破坏也是不可弥补的.以下罗列的10款SQL注入工具可帮助管理员及时检测存在的漏洞. BSQL Hacker 1 ...
- GridView控件-01-[简单的数据显示]
GridView绑定数据分为两种,一种是多值绑定,另一种是字段绑定. 多值绑定(直接绑定到数据源就行,不需要使用字段): 前台代码: <asp:GridView ID="GridVie ...
- tomcat设置IP地址或者域名访问
链接地址:http://jingyan.baidu.com/article/7e440953dc096e2fc0e2ef1a.html 本文介绍如何通过修改tomcat的配置,实现通过IP地址或者域名 ...
- HDOJ 1005
Input The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a ...
- GDSOI2015 task2 覆盖半径
题目大意 一个\(n\times m\)的矩阵中有\(p\)个已经确定圆心的圆,并且每个格子有一定的分数,如果一个格子被任意一个或以上的圆覆盖,那么就可以得到这个格子的分数.现在求最小的半径,使得得分 ...
- mysql备份数据库几种方法
方法一 cmd 到mysql bin文件夹下用 例如以下命令 mysqldump --opt -h192.168.0.156 -uusername -ppassword --skip-lock-tab ...