标签:
2 3 2 1 2 3 3 3 1 2 3
Case #1: 4 Case #2: 2HintIn the ?rst sample, Matt can win by selecting: friend with number 1 and friend with number 2. The xor sum is 3. friend with number 1 and friend with number 3. The xor sum is 2. friend with number 2. The xor sum is 2. friend with number 3. The xor sum is 3. Hence, the answer is 4.
#include<map> #include<string> #include<cstring> #include<cstdio> #include<cstdlib> #include<cmath> #include<queue> #include<vector> #include<iostream> #include<algorithm> #include<bitset> #include<climits> #include<list> #include<iomanip> #include<stack> #include<set> using namespace std; long long dp[2][1<<20]; int val[50]; int main() { int T; cin>>T; for(int cs=1;cs<=T;cs++) { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>val[i]; int len=1<<20; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i=1;i<=n;i++) for(int j=0;j<len;j++) dp[i&1][j]=dp[(i-1)&1][j]+dp[(i-1)&1][j^val[i]]; long long ans=0; for(int i=m;i<len;i++) ans+=dp[n&1][i]; printf("Case #%d: %lld\n",cs,ans); } }
标签:
原文地址:http://blog.csdn.net/stl112514/article/details/44201373