HDU 4876 ZCC loves cards
来源:互联网 发布:c语言图书管理系统 编辑:程序博客网 时间:2024/05/16 08:58
ZCC loves playing cards. He has n magical cards and each has a number on it. He wants to choose k cards and place them around in any order to form a circle. He can choose any several consecutive cards the number of which is m(1<=m<=k) to play 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, butonce 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 rangeL,R , it doesn’t matter. Help him to find the maximal R.
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
You can assume that all the test case generated randomly.
4 3 12 3 4 5
7暴力枚举C(n,k)的组合,对于组合内的选择,做一次2^k的剪枝,不行就暴力k!#include<map>#include<set>#include<ctime>#include<cmath>#include<queue>#include<string>#include<vector>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<functional>using namespace std;#define ms(x,y) memset(x,y,sizeof(x))#define rep(i,j,k) for(int i=j;i<=k;i++)#define per(i,j,k) for(int i=j;i>=k;i--)#define loop(i,j,k) for (int i=j;i!=-1;i=k[i])#define inone(x) scanf("%d",&x)#define intwo(x,y) scanf("%d%d",&x,&y)#define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z)#define infou(x,y,z,p) scanf("%d%d%d%d",&x,&y,&z,&p)#define lson x<<1,l,mid#define rson x<<1|1,mid+1,r#define mp(i,j) make_pair(i,j)#define ft first#define sd secondtypedef long long LL;typedef pair<int, int> pii;const int low(int x) { return x&-x; }const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 1e5 + 10;const double eps = 1e-10;int n,m,L,a[N],b[N],c[N],d[N],cnt,R;void check(){ ++cnt; rep(i,1,(1<<m)-1) { int now=0; rep(j,0,m-1) if (i&(1<<j)) now^=b[j]; c[now]=cnt; } int G=0; for (int i=L;c[i]==cnt;i++) G=max(G,i); if (R>=G) return; rep(i,0,m-1) d[i]=b[i]; do { ++cnt; rep(i,0,m-1) { int now=0; rep(j,0,m-1) { c[now^=d[(i+j)%m]]=cnt; } } for (int i=L;c[i]==cnt;i++) R=max(R,i); }while (next_permutation(d,d+m));}void dfs(int x,int y){ if (y==m) { check(); return;} if (x>n) return; dfs(x+1,y); b[y]=a[x]; dfs(x+1,y+1);}int main(){ cnt=0; while (~inthr(n,m,L)) { rep(i,1,n) inone(a[i]); sort(a+1,a+n+1); R=0; dfs(1,0); printf("%d\n",R); } return 0;}
0 0
- HDU 4876 ZCC loves cards
- HDU-4876-ZCC loves cards
- hdu 4876 ZCC loves cards
- HDU 4876 ZCC loves cards
- HDU 4876 ZCC loves cards
- 【HDU 4876多校】ZCC loves cards【搜索】
- hdu 4876 ZCC loves cards(暴力)
- HDU 4876 ZCC loves cards(暴力剪枝)
- 【HDU】4876 ZCC loves cards 暴力
- hdu 4876 ZCC loves cards (搜索+剪枝)
- HDOJ 4876 ZCC loves cards
- hdu 4876 ZCC loves cards(暴力+剪枝)
- hdu 4876 ZCC loves cards(暴搜+剪枝)
- HDU 4876 ZCC loves cards【暴力+深搜+剪枝】
- [HDOJ 4876] ZCC loves cards [搜索]
- HDOJ 4876 ZCC loves cards(搜索)
- HDU4876 ZCC loves cards
- HDU4876:ZCC loves cards
- Hive源码调试步骤
- <Linux多线程服务端编程>学习记录
- Java 网络编程简单学习笔记1
- 关于adb
- 72. Edit Distance
- HDU 4876 ZCC loves cards
- ubuntu中配置samba方法
- CentOS中更改IPV4和IPV6地址以及路由
- 307. Range Sum Query
- 关于锁(悲观锁与乐观锁)
- 冒泡排序法
- 树莓派 忘记密码的解决方法
- Java基础之注解Annotation初入篇_雷惊风
- Eclipse xml 无自动提示