codeforces Fedor and New Game

简介:

#include<iostream>
#include<stack>
#include<cstring>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;

int a[1005];

int main(){
    int n, m, k;
    int ans, ret=0;
    scanf("%d%d%d", &n, &m, &k);
    for(int i=1; i<=m; ++i)
        scanf("%d", &a[i]);
    scanf("%d", &ans);
    for(int i=1; i<=m; ++i){
        int tmp = ans^a[i], cnt=0;
        while(tmp){
            if(tmp&1) ++cnt;
            tmp>>=1;
        }
        if(cnt<=k)  ++ret;
    } 
    printf("%d\n", ret);
    return 0;
}

目录
相关文章
LeetCode 390. Elimination Game
给定一个从1 到 n 排序的整数列表。 首先,从左到右,从第一个数字开始,每隔一个数字进行删除,直到列表的末尾。 第二步,在剩下的数字中,从右到左,从倒数第一个数字开始,每隔一个数字进行删除,直到列表开头。 我们不断重复这两步,从左到右和从右到左交替进行,直到只剩下一个数字。 返回长度为 n 的列表中,最后剩下的数字。
93 0
LeetCode 390. Elimination Game
|
存储 算法
LeetCode 289. Game of Life
如果活细胞周围八个位置的活细胞数少于两个,则该位置活细胞死亡; 如果活细胞周围八个位置有两个或三个活细胞,则该位置活细胞仍然存活; 如果活细胞周围八个位置有超过三个活细胞,则该位置活细胞死亡; 如果死细胞周围正好有三个活细胞,则该位置死细胞复活;
69 0
LeetCode 289. Game of Life
codeforces327——A. Flipping Game(前缀和)
codeforces327——A. Flipping Game(前缀和)
80 0
|
人工智能
Codeforces 839B Game of the Rows【贪心】
B. Game of the Rows time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output...
1153 0
[LeetCode] Game of Life
A solution using additional spaces to solve a copy of the original board is easy. To get an in-place solution, we need to record the information of state transitions directly in the board.
714 0