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. YII 路由配置

    伪静态,通过设置server服务,做域名地址的转换工作. urlManager地址美化,通过程序的方式实现地址美化工作. 通过在主配置文件里配置组件来实现: 'components'=>arra ...

  2. 关于apche无缘无故个启动不了,解决方法

    1. 对于用户不小心把apache下的conf文件不小心给修改了,可那会导致,启动不了apache, 解决办法可以重新下载一个, 64为  32位  下载地址 http://www.veryhuo.c ...

  3. BZOJ 3438: 小M的作物( 最小割 )

    orz出题人云神... 放上官方题解... 转成最小割然后建图跑最大流就行了... ---------------------------------------------------------- ...

  4. Android GsonUtils工具类

    有那么一个开源jar包,叫gson 可以很方便的将java中的对象和字符串相互转化,数据传输和处理的时候,用到的可能性很大 https://github.com/google/gson http:// ...

  5. shell中exec解析(转)

    参考:<linux命令.编辑器与shell编程> <unix环境高级编程> exec和source都属于bash内部命令(builtins commands),在bash下输入 ...

  6. 6.6.2 自己主动泛型化(automatic generalization)

    6.6.2 自己主动泛型化(automatic generalization) 在这一章,我们已经实现了几个 F# 的高阶函数.也看到了在 F# 和 C# 中并排的实现.F# 实现的非常重要方面,是我 ...

  7. linux命令: mount

    mount使用示例: #mkdir -p /mnt/usbhd1 注:建立目录用来作挂接点(mount point) #mount -t ntfs /dev/sdc1 /mnt/usbhd1 (-t ...

  8. BZOJ 2705: [SDOI2012]Longge的问题( 数论 )

    T了一版....是因为我找质因数的姿势不对... 考虑n的每个因数对答案的贡献. 答案就是 ∑ d * phi(n / d) (d | n) 直接枚举n的因数然后求phi就行了. 但是我们可以做的更好 ...

  9. JSP 网页格式判定执行哪一块html

    JSP 网页格式判定执行哪一块html <!-- start -->             <td height="166" colspan="3&q ...

  10. 利用Ihttpmodel实现网站缓存,解决Server.Transfer 直接输出HTML源代码的问题

    今天在用.NET利用IHttpModel实现网站静态缓存的时候,不知道最后为什么用 Server.Transfer(html)的时候结果输出的是HTML的源代码. 贴上源代码 using System ...