B. Fedor and New Game

发布时间 2023-09-04 19:05:59作者: 是吃可爱长大的

B. Fedor and New Game

https://codeforces.com/problemset/problem/467/B

"""
467B
思路:
1.暴力方法:
通过循环二进制之后的,逐个位与fedor进行判断,通过取余,如果最后不同的超过3个就计+1

2.解决方法:
通过异或^进行判断,然后转成二进制,统计1的数量,就是不同的数量,然后相加

"""
# 利用异或取得的二进制,相同是0不同是1,取其中的1的数量,ok的话ans就加1
# .count可以对二进制使用
n, m, k = map(int, input().split())
xi = map(int, [input() for _ in range(m)])
fedor = int(input())
ans = 0
for i in xi:
    if bin(i ^ fedor).count('1') <= k:
        ans += 1
print(ans)

# another
# [i for i in (1, 2, 3)]    [1, 2, 3]
# [i <= 2 for i in (1, 2, 3)]   [False, True, True]
# 可以把列表推导式理解为, 前面表达式然后append进数组里
# 第一种就是append(i), 第二种就是append(i<=k), 所以获得了一个布尔数组, sum对布尔数组True默认是1,False是0
lines = [*open(0)]
n, m, k = map(int, lines[0].split())
xi = map(int, lines[1:-1])
fedor = int(lines[-1])
print(sum(bin(fedor ^ i).count('1') <= k for i in xi))