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

【分析】:
“<< ”   位左移,相当于乘以2
“>>" 位右移,相当于除以2
“&” 按为与,位数都为1时为1,否则为0
“^” 异或,不同为1,相同为0 新技能: a & ( << j ) 表示数a二进制的第j位是什么
【代码】:
#include <bits/stdc++.h>

using namespace std;
const int maxn = ;
int n,m,k,a[maxn]; int main()
{
int sum=,ans=;
cin>>n>>m>>k;
for(int i=;i<=m;i++)
cin>>a[i];
for(int i=;i<m;i++)
{
sum=; //注意内部清零
for(int j=;j<n;j++)
if( ( a[i]&(<<j) )^( a[m]&(<<j) ) ) sum++;
if(sum<=k) ans++;
} cout<<ans<<endl;
return ;
}

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

  1. 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 ...

  2. Divide by Zero 2021 and Codeforces Round #714 (Div. 2) B. AND Sequences思维,位运算 难度1400

    题目链接: Problem - B - Codeforces 题目 Example input 4 3 1 1 1 5 1 2 3 4 5 5 0 2 0 3 0 4 1 3 5 1 output 6 ...

  3. 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 ...

  4. Codeforces Round #267 Div.2 D Fedor and Essay -- 强连通 DFS

    题意:给一篇文章,再给一些单词替换关系a b,表示单词a可被b替换,可多次替换,问最后把这篇文章替换后(或不替换)能达到的最小的'r'的个数是多少,如果'r'的个数相等,那么尽量是文章最短. 解法:易 ...

  5. 01背包 Codeforces Round #267 (Div. 2) C. George and Job

    题目传送门 /* 题意:选择k个m长的区间,使得总和最大 01背包:dp[i][j] 表示在i的位置选或不选[i-m+1, i]这个区间,当它是第j个区间. 01背包思想,状态转移方程:dp[i][j ...

  6. Codeforces Round #267 (Div. 2) C. George and Job(DP)补题

    Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently ...

  7. Codeforces Round #390 (Div. 2) D. Fedor and coupons(区间最大交集+优先队列)

    http://codeforces.com/contest/754/problem/D 题意: 给定几组区间,找k组区间,使得它们的公共交集最大. 思路: 在k组区间中,它们的公共交集=k组区间中右端 ...

  8. Codeforces Round #267 (Div. 2)

    A #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> ...

  9. Codeforces Round #267 (Div. 2) C. George and Job DP

                                                  C. George and Job   The new ITone 6 has been released ...

随机推荐

  1. objc中的类方法和实例方法有什么本质区别和联系

    类方法: 类方法是属于类对象的 类方法只能通过类对象调用 类方法中的self是类对象 类方法可以调用其他的类方法 类方法中不能访问成员变量 类方法中不能直接调用对象方法 类方法是存储在元类对象的方法缓 ...

  2. Activiti入门 -- 环境搭建和核心API简介

    相关文章: <史上最权威的Activiti框架学习指南> <Activiti入门 -- 轻松解读数据库> 本章内容,主要讲解Activiti框架环境的搭建,能够使用Activi ...

  3. 【Kernel Logistic Regression】林轩田机器学习技术

    最近求职真慌,一方面要看机器学习,一方面还刷代码.还是静下心继续看看课程,因为觉得实在讲的太好了.能求啥样搬砖工作就随缘吧. 这节课的核心就在如何把kernel trick到logistic regr ...

  4. HTML5 FileReader接口学习笔记

    1.FileReader概述 FileReader 对象允许Web应用程序异步读取存储在用户计算机上的文件(或原始数据缓冲区)的内容,使用 File 或 Blob 对象指定要读取的文件或数据. 其中F ...

  5. 安卓context(一)

    最近看了一下深入安卓内核,毫无安卓基础的我一头深入不可自拔,看的是云里雾里,第一遍看到一半左右似乎开始失去了效率. 现在开始第二遍,并对看过的重要知识点以个人的理解进行梳理(不免有错的地方,好心人请告 ...

  6. 团队Alpha版本(七)冲刺

    目录 组员情况 组员1(组长):胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:翟丹丹 组员7:何家伟 组员8:政演 组员9:黄鸿杰 组员10:刘一好 组员11:何宇恒 展示 ...

  7. 【JAVA进阶】——myEclipse连接mysql启动数据库服务

    背景: DRP项目要求使用Oracle数据库,但目前由于种种原因,暂时还装不了Oracle.但也不能闲着啊,就拿mysql来试试.安装完mysql以后,使用myEclipse连接数据库,就一直报错,报 ...

  8. (总结)Nginx 502 Bad Gateway错误触发条件与解决方法

    一些运行在Nginx上的网站有时候会出现“502 Bad Gateway”错误,有些时候甚至频繁的出现.以下是从Google搜集整理的一些Nginx 502错误的排查方法,供参考: Nginx 502 ...

  9. PHP面向对象关键词static 、self

    知识点: 一.static可以修饰类内的属性或方法,被修饰的属性或方法在类外部,不能被实例化成对象访问,而是使用类本身进行访问,而静态的方法如果想使用静态的属性,则需要用self::这样的写法来访问静 ...

  10. Block层也是有IO的优先级的

    ---恢复内容开始--- 今天查看iotop的原理,竟然发现了IO优先级一说,IO是block层cfs调度器中的概念 block层也有一个类似于CPU的调度算法 对进程分成三个级别:RT,BE,IDL ...