B. Fedor and New Game
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».

The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type.

Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends.

Input

The first line contains three integers nmk (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000).

The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player.

Output

Print a single integer — the number of Fedor's potential friends.

Sample test(s)
input
7 3 1
8
5
111
17
output
0
input
3 3 3
1
2
3
4
output
3

sb题*2

给m个数,转成二进制,问和给定的x的每一位异或和小等于k的有多少个

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,k,ans,a[100100];
int work(int x)
{
int res=0;
for(int i=0;i<=21;i++)
if((x&(1<<i))^(m&(1<<i)))res++;
return res;
}
int main()
{
scanf("%d%d%d",&m,&n,&k);
int x,y;
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
scanf("%d",&m);
for(int i=1;i<=n;i++)
if(work(a[i])<=k)ans++;
printf("%d",ans);
return 0;
}

  

cf467B Fedor and New Game的更多相关文章

  1. codeforces754D Fedor and coupons

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  2. codeforces 754D. Fedor and coupons

    D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  3. CF467D Fedor and Essay 建图DFS

      Codeforces Round #267 (Div. 2) CF#267D D - Fedor and Essay D. Fedor and Essay time limit per test ...

  4. Codeforces 390Div2-754D. Fedor and coupons(贪心+优先队列)

    D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  5. hackerrank Alex对战Fedor

    任意门 为了在漫长得飞行旅途中娱乐,Alex和Fedor发明了如下的一个简单的双人游戏.游戏是: 首先, Alex画一个有权无向图.该图中可能有多重边(多重边的权值可能相同或者不同). 然后,Fedo ...

  6. Codeforces Round #267 (Div. 2) D. Fedor and Essay tarjan缩点

    D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Round #267 (Div. 2) B. Fedor and New Game【位运算/给你m+1个数让你判断所给数的二进制形式与第m+1个数不相同的位数是不是小于等于k,是的话就累计起来】

    After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...

  8. CodeForces 467D(267Div2-D)Fedor and Essay (排序+dfs)

    D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #267 (Div. 2) B. Fedor and New Game

    After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...

随机推荐

  1. 数据库下载word预览功能的研究

    本文参考了这里的一些方法http://tobetobe.blog.51cto.com/1392243/354420 一直想通过缓存来实现,奈何技术不够,走了曲线救国的思路,先下载,然后预览,删除下载文 ...

  2. Linux命令之xargs的分析及隐患

    写一个main.c: #include <stdio.h> int main(){ printf("foo"); printf("bar"); re ...

  3. Fragment与Activity相互传递数据:

    Activity向Fragment传递数据:在Activity中创建Bundle数据包,并调用Fragment的setArguments(Bundle bundle)方法即可将Bundle数据包传给F ...

  4. TCP连接探测中的Keepalive和心跳包. 关键字: tcp keepalive, 心跳, 保活

    1. TCP保活的必要性 1) 很多防火墙等对于空闲socket自动关闭 2) 对于非正常断开, 服务器并不能检测到. 为了回收资源, 必须提供一种检测机制. 2. 导致TCP断连的因素 如果网络正常 ...

  5. Windows搭建Sublime Text 3 + Go开发环境

    1. 安装Sublime Text 3 Sublime Text 3(以下简称ST)的下载与安装我就不说啦,目前还是一个测试版,不过据说比ST2增加了好多新功能,下载地址: http://www.su ...

  6. perl return和break

    zjzc01:/root/test# cat a3.pl sub mask { my $n=shift; my $j =100; for ($i = 1;$i <= 5;$i++){ print ...

  7. jQuery UI 之 LigerUI 快速入门

    LigerUI 快速开发UI框架 LigerUI 是基于jQuery 的UI框架,其核心设计目标是快速开发.使用简单.功能强大.轻量级.易扩展.简单而又强大,致力于快速打造Web前端界面解决方案,可以 ...

  8. Contains Duplicate 解答

    Question Given an array of integers, find if the array contains any duplicates. Your function should ...

  9. Jump Game 解答

    Question Given an array of non-negative integers, you are initially positioned at the first index of ...

  10. Android学习总结——实现Home键功能

    实现Home键功能简而言之就是回到桌面,让Activity不销毁,程序后台运行. 实现方法: Intent intent= new Intent(Intent.ACTION_MAIN); intent ...