Test instructions: With up to 40 numbers, take any number their XOR and >=k are a viable option and ask how many feasible options.
Analysis: Dp[now][j] Indicates the current number of this value, then the transfer equation is dp[now][j] = Dp[pre][j] + dp[pre][j^a[i]]. Because of A^b=c's words, c^b=a, so j^a[i] can be transferred to the state of J through XOR or A[i]. You can then compress it with a scrolling array.
The code is as follows:
1#include <stdio.h>2#include <algorithm>3#include <string.h>4 using namespacestd;5typedefLong Longll;6 7 Const intLim =1<< -;8 9 intn,k;Ten inta[ -]; Onell dp[2][lim]; A - intMain () - { the intT;SCANF ("%d",&T); - for(intKase=1; kase<=t;kase++) - { -scanf"%d%d",&n,&k); + for(intI=1; i<=n;i++) scanf ("%d", A +i); - +Memset (DP,0,sizeof(DP)); Adp[0][0] =1; at intnow =0; - for(intI=1; i<=n;i++) - { -now =1-Now ; - for(intj=0; j<lim;j++) - { inDP[NOW][J] = dp[1-NOW][J] + dp[1-now][j^A[i]]; - } to } +ll ans =0; - for(inti=k;i<lim;i++) ans + =Dp[now][i]; theprintf"Case #%d:%i64d\n", Kase,ans); * } $}
HDU 5119 Happy Matt friends--(backpack DP)