HDU4876:ZCC loves cards,hdu4876zcc

來源:互聯網
上載者:User

HDU4876:ZCC loves cards,hdu4876zcc
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 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, but 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  用全排列的方法來做,這我一開始還真沒想到
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int n,k,l,r;int vis[500],a[500],tem[500],s[500];void set(int len,int sum){    vis[sum] = 1;    if(len == k)        return ;    set(len+1,sum^tem[len]);    set(len+1,sum);}int check(){    memset(vis,0,sizeof(vis));    set(0,0);    for(int i = l; i<=r; i++)        if(!vis[i])            return 0;    return 1;}void solve(){    if(!check()) return ;    int i,j;    for(i = 0; i<k; i++)        s[i] = tem[i];    do    {        memset(vis,0,sizeof(vis));        for(i = 0; i<k; i++)        {            int ans = 0;            for(j = i; j<k+i; j++)            {                ans^=s[(j%k)];                vis[ans] = 1;            }        }        for(i = l; i<=128; i++)//a[i]最大100,所以不會超過128            if(!vis[i])            {                r = max(r,i-1);                break;            }    }    while(next_permutation(s+1,s+k));}void dfs(int now,int len){    if(len == k)    {        solve();        return ;    }    for(int i = now; i<n; i++)    {        tem[len] = a[i];        dfs(i+1,len+1);    }}int main(){    int i,j;    while(~scanf("%d%d%d",&n,&k,&l))    {        for(i = 0; i<n; i++)            scanf("%d",&a[i]);        sort(a,a+n);//先排序,方便後面進行排列        r = l-1;        dfs(0,0);        if(r<l)            printf("0\n");        else            printf("%d\n",r);    }    return 0;}



ZCC:="XSTDZC#";{這句引用周K線的收盤價,公式自己建立} ZS:ZCC*1085; ZJ:ZCC*0925;



 
哪位朋友知道:ZCC、CT FMA01_160_B40_SEIZ_10盤銑刀是哪個國家生產的?

國產,株洲鑽石的,ZCC.CT是株洲鑽石切削刀具股份有限公司的英文簡稱!
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.