HDOJ 4876 ZCC loves cards

Source: Internet
Author: User

HDOJ 4876 ZCC loves cards


Enumerative combination: determines whether L... R can be overwritten without considering the continuity. This is a huge reduction for random data.

Brute-force detection once


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


Problem DescriptionZCC 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 ConsecutiveCards 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 127a2... when am, which ai means the number on the ith card he chooses. he can play the magic infinite times, 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.
InputThe input contains several test cases. the first line in each case contains three integers n, k and L (k ≤ n ≤ 20, 1 ≤ k ≤ 6, 1 ≤ L ≤ 100 ). the next line contains n numbers means the numbers on the n cards. the ith number a [I] satisfies 1 ≤a [I] ≤100.
You can assume that all the test case generated randomly.
OutputFor each test case, output the maximal number R. And if L can't be obtained, output 0.
Sample Input
4 3 12 3 4 5

Sample Output
7Hint ⊕ means xor  

Author Zhenhai Middle School
Source2014 Multi-University Training Contest 2
RecommendWe have carefully selected several similar problems for you: 4881 4880 4879 4878 4877
Statistic | Submit | Discuss | Note



#include 
 
  #include 
  
   #include 
   
    #include 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
    
     

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.