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 ...
随机推荐
- HttpClient, HttpClientHandler, and WebRequestHandler介绍
注:本文为个人学习摘录,原文地址:https://blogs.msdn.microsoft.com/henrikn/2012/08/07/httpclient-httpclienthandler-an ...
- asp.net接收发送的xml字符串数据
最近研究为新的接口,发现发送的消息的格式为xml类型.之前接口接触的多是接收json类型的数据,可以直接通过Request["Key"]/Request.QueryString[& ...
- Linode开通新加坡机房:vps速度快,价格不变!
vps服务商linode终于开通了新加坡机房中心,这是linode全球第7个机房,满足日益增长的东南亚市场需求.印度.中国.澳大利亚及周边国家都有很好的用户体验. linode新加坡机房采用思科Cis ...
- Arch最小化安装LXDE桌面环境
安装最小化的LXDE桌面环境: pacman -S lxde-common 安装LXDE Session: pacman -S lxsession 不安装这个没法登录进桌面环境 安装LXDE面板: p ...
- linux双线ip设置(不需额外增加路由表)
linux 双线ip设置(不需额外增加路由表,只需修改下面就ok了)修改 vi /etc/iproute2/rt_tables (增加电信和网通两个路由表) 增加252 ...
- javascript动画效果之多物体缓冲运动
这个是通过一个for循环控制的三个li标签,被鼠标触发则会有一个宽度增加和减少的事件 html和css同样写在一起方便察看,这里就是简单的布局,重点在js <!DOCTYPE html> ...
- Pots(BFS)
Pots Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submiss ...
- java集合概念
Collection(单列集合) List(有序,可重复) ArrayList 底层数据结构是数组,查询快,增删慢 线程不安全,效率高 Vector 底层数据结构是数组,查询快,增删慢 线程安全,效率 ...
- 配置mac自带的Apache服务器
第一步: 484 cd /etc/apache2 备份httpd.conf文件,以防万一 486 sudo cp httpd.conf httpd.conf.bak 如果操作错误,可以通过 491 ...
- 滚动条加粗和panel,gridControl结合用
private void FrmLotterycs_Load(object sender, EventArgs e) { t = 0; UserJuanquanTB = O.get_UserJuanq ...