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 _(:зゝ∠)_ 随机输出保平安的更多相关文章

  1. HDU 4876 ZCC loves cards(暴力剪枝)

    HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...

  2. hdu 4876 ZCC loves cards(暴力)

    题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...

  3. HDOJ 4876 ZCC loves cards

    枚举组合,在不考虑连续的情况下推断能否够覆盖L...R,对随机数据是一个非常大的减枝. 通过检測的暴力计算一遍 ZCC loves cards Time Limit: 4000/2000 MS (Ja ...

  4. hdu 4873 ZCC Loves Intersection(大数+概率)

    pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...

  5. 多校训练赛2 ZCC loves cards

    ZCC loves cards Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  6. HDU 4873 ZCC Loves Intersection(可能性)

    HDU 4873 ZCC Loves Intersection pid=4873" target="_blank" style="">题目链接 ...

  7. hdu 4882 ZCC Loves Codefires(数学题+贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...

  8. hdu 5288 ZCC loves straight flush

    传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K ...

  9. HDU 5228 ZCC loves straight flush( BestCoder Round #41)

    题目链接:pid=5228">ZCC loves straight flush pid=5228">题面: pid=5228"> ZCC loves s ...

随机推荐

  1. java入门(1) 程序运行机制及运行过程

    首先我们来看一下java程序在底层是怎么工作的: JAVA有两种核心机制: Java虚拟机(Java Virtual Machine): 1.java虚拟机可以理解成一个以字节码为机器指令的CPU. ...

  2. SuperSocket源码解析之会话生命周期

    一 基本概念 会话(Session)是客户端与服务器进行通信的基本单元,也是一个Socket的封装,在http协议中也有Session机制,其主要作用封装一个通信单元socket,负责服务器与客户端消 ...

  3. MFC:重绘Button,定制CButton,自画CPngButton,求赐教(各种bug包括性能bug)谢谢谢谢

    [1.]CPngButton.h(资源是最后图片) #pragma once #include<atlimage.h> #define PNUM 19 #define PLAYTIME 1 ...

  4. asp.net 中将汉字转换成拼音

    /// <summary> /// 获取汉字的全拼音 /// </summary> /// <param name="x">传汉字的字符串< ...

  5. flex调用webservice中的datatable结果写入datagrid

    webservice配置文件 <appSettings> <add key="sqlConDuke" value="server=10.9.34.88; ...

  6. Writing a ServiceMain Function(使用RegisterServiceCtrlHandler函数)

    The following global definitions are used in this sample. C++   #define SVCNAME TEXT("SvcName&q ...

  7. 程序启动报错:ORA-12505;PL/SQL却可以登录的解决方法

    一.异常{ ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connect ...

  8. DOM方法入门 - 第二课

    1.console.log()是吧元素显示在控制台2.appendChild() 就是将元素追加到末尾3.innerHTML获取的是元素里面的所有内容包括里面的子元素4.innerText获取的是元素 ...

  9. [linux]linux命令学习-netstat

    linux非常多服务都与网络相关.当服务调不通或者是启动port被占用,或者是又是被防火墙挡住的时候,就须要查询网络相关的问题,netstat命令之前仅仅会用一两个參数这里.好好学习一番. 经常使用的 ...

  10. SharePoint数据视图无法打开

    最近在折腾SharePoint,之前列表常用的“数据视图”居然不能打开,提示“没有安装Sharepoit foundation 数据兼容组件”如图: 上网G下.度下有说要删除注册表.要安装office ...