Test instructions: n items, the weight of the article I is Ki, select some items to make them different or not less than M, how many options
Data range: 1 <= n <= 40,0 <= m <= 1e6
Idea: In fact, is a request for a backpack, MX to open more than 1e6, not scrolling array can also pass.
The old routine set Dp[i][j] for the first I item xor, dp[i][j] = Dp[i-1][j] + dp[i-1][j^a[i]], and finally sum the values of dp[n][m above]
1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineLL Long Long5 using namespacestd;6 7 Const intMX =1<< -;8 inta[ -];9LL dp[ -][mx+Ten];Ten One intMain () { A intT, Kase =0; -scanf"%d", &t); - while(t--){ the intN, M; -Memset (DP,0,sizeofDP); -LL ans =0; -scanf"%d%d", &n, &m); + for(inti =1; I <= N; i++) -scanf"%lld", &a[i]); +dp[0][0] =1; A for(inti =1; I <= N; i++) at for(intj =0; J <= MX; J + +) -DP[I][J] = dp[i-1][J] + dp[i-1][j^A[i]]; - for(inti = m; i < MX; i++) -Ans + =Dp[n][i]; -printf"Case #%d:%lld\n", ++Kase, ans); - } in return 0; -}
HDU-5119 Happy Matt Friends (backpack DP, Recursive enumeration)