Happy Matt Friends
Happy Matt Friends
Time Limit: 6000/6000 MS (Java/Others) Memory Limit: 510000/510000 K (Java/Others)
together.
Each of Matt’s friends has a magic number. In the game, Matt
selects some (could be zero) of his friends. If the xor (exclusive-or) sum of
the selected friends’magic numbers is no less than M , Matt wins.
Matt
wants to know the number of ways to win.
indicates the number of test cases.
For each test case, the first line
contains two integers N, M (1 ≤ N ≤ 40, 0 ≤ M ≤ 106).
In the
second line, there are N integers ki (0 ≤ ki ≤ 106),
indicating the i-th friend’s magic number.
where x is the case number (starting from 1) and y indicates the number of ways
where Matt can win.
3 2
1 2 3
3 3
1 2 3
Case #2: 2
In the first 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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
const int maxn=2e6+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
inline ll read()
{
ll x=;int f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int n,m,k,t,cas;
ll dp[][maxn],ans;
int main()
{
int i,j;
scanf("%d",&t);
while(t--)
{
memset(dp,,sizeof(dp));
ans=;
dp[][]=;
scanf("%d%d",&n,&m);
rep(i,,n)
{
scanf("%d",&k);
for(j=;j<=1e6;j++)dp[i%][j]=dp[(i-)%][j]+dp[(i-)%][j^k];
}
rep(i,m,1e6)ans+=dp[n%][i];
printf("Case #%d: %lld\n",++cas,ans);
}
//system("Pause");
return ;
}
Happy Matt Friends的更多相关文章
- [Under the hood]---Matt Pietrek October 1996 MSJ
Matt Pietrek October 1996 MSJ Matt Pietrek is the author of Windows 95 System Programming Secrets (I ...
- hdu 5112 A Curious Matt
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5112 A Curious Matt Description There is a curious ma ...
- HDU 5119 Happy Matt Friends
Happy Matt Friends Time Limit: 6000/6000 MS (Java/Others) Memory Limit: 510000/510000 K (Java/Others ...
- HDU 5112 A Curious Matt 水题
A Curious Matt Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- hdoj 5112 A Curious Matt
A Curious Matt Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) ...
- 水题:HDU 5119 Happy Matt Friends
Matt has N friends. They are playing a game together.Each of Matt's friends has a magic number. In t ...
- 水题:HDU 5112 A Curious Matt
Description There is a curious man called Matt. One day, Matt's best friend Ted is wandering on the ...
- 听听Matt Rogish说怎么面试程序员
Google的人力运营高级副总裁Laszlo Bock在一次采访中说Google发现在面试程序员时问智力题完全是浪费时间,Matt Rogish在他的这篇博客How to Interview Prog ...
- Happy Matt Friends(dp)
Happy Matt Friends Time Limit: 6000/6000 MS (Java/Others) Memory Limit: 510000/510000 K (Java/Oth ...
随机推荐
- Python 处理文件
1.从现有文件中获取信息 使用Python中的模块,可以从现有文件中获取信息.使用“os”模块和“stat”模块可以获取文件的基本信息: import os import stat import ti ...
- Myeclipse 激活代码 8.6以前的版本
public class Akey { private static final String LL = "Decompiling this copyrighted software is ...
- HttpReceiveRequestEntityBody 使用应注意的地方
如果EntityBody数据很大,调用此函数是不能完全接收全部数据的,我们不能简单的判断 1: BYTE* pBuffer = new BYTE[4096]; 2: ZeroMemory(pBuffe ...
- java实现树型结构样式
import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; public class Root exten ...
- 复用TCP连接提升流媒体服务器之间流量转发效率
由于媒体推流客户端所在地域不同.所接入网络运营商不同.就近接入原则等因素,导致不同的视频推流客户端会推流至不同的流媒体服务器(本文主要针对目前WEB或手机的基于TCP的流媒体服务器),在某流媒体服务器 ...
- 运行指定路径下的exe
public void StartProcess(string name) { string exeFileName = "DataControl.exe"; string sta ...
- 错误提示 Unsupported compiler 'com.apple.compilers.llvmgcc42' selected for architecture 'i386'
转自http://blog.csdn.net/cyuyanenen/article/details/51444974 警告提示:Invalid C/C++ compiler in target Cor ...
- 有关android安全性的问题--代码混淆
转自:http://www.cnblogs.com/dream-sky/archive/2012/11/15/2771648.html 在project.properties里加上 proguar ...
- hdu_4651_Partition(公式)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4651 题意:给你一个数n,让你输出将n拆分的方案数. 题解:公式题,不解释,当模版记住就行 #incl ...
- 1213 How Many Tables 简单的并查集问题
my code: #include <cstdio>#include <cstring>#include<iostream>using namespace std; ...