codeforces—— 467B —— Fedor and New Game
来源:互联网 发布:正常饮食知乎 编辑:程序博客网 时间:2024/06/10 23:14
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.
The first line contains three integers n, m, k (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.
Print a single integer — the number of Fedor's potential friends.
7 3 18511117
0
3 3 31234
3
输入n,m,k.输入m+1个数,取值小于等于n,问最后输入的数与其余的数,在二进制下差别不超过k位的有多少个
#include<iostream>#include<cmath>#include<cstdio>#include<map>#include<set>#include<cstring>#include<string>#include<algorithm>#define min 1e-6using namespace std;int main(){ int temp,n,m; while(cin>>temp>>n>>m) { int self,com[1008]; temp=n; while(temp--) cin>>com[temp]; cin>>self; int ans=0; for(int i=0; i<n; i++) { temp=m; for(int j=0; j<32; j++) if(((com[i]>>j)&1)!=((self>>j)&1)) temp--; if(temp>=0) ans++; } cout<<ans<<endl; } return 0;}
- codeforces—— 467B —— Fedor and New Game
- Codeforces 467B Fedor and New Game
- Codeforces 467B Fedor and New Game
- 【CODEFORCES】 B. Fedor and New Game
- Codeforces 467B Fedor and New Game(暴力)
- cf-467B. Fedor and New Game
- B. Fedor and New Game
- Codeforces Round #267 (Div. 2) B. Fedor and New Game
- Codeforces Round #267 (Div. 2) B. Fedor and New Game
- CF 267B Fedor and New Game
- Fedor and New Game
- Codeforces Round #267 (Div. 2) B. Fedor and New Game(位运算)
- 二进制新知识(Codeforces Round #267 (Div. 2) B. Fedor and New Game)
- #267B. Fedor and New Game-----每日两道水(1)
- cf467B Fedor and New Game
- codeforces467D——Fedor and Essay
- Codeforces 467D Fedor and Essay bfs
- Codeforces 467D. Fedor and Essay
- Resource interpreted as Document but transferred with MIME type application/json:
- Android中Activity.this,getApplicationContext(),getBaseContext()和this详解
- 移动端web开发技巧
- 链表中倒数第k个结点
- AES128加密解密以及参数的处理
- codeforces—— 467B —— Fedor and New Game
- ionic中如何隐藏头部的返回按钮
- ThreadLocal工作原理
- maven添加oracle jdbc依赖
- Java GUI Button组件上的内容中文乱码问题
- linux(windows)之svn重定向地址
- Unity用Vuforia做AR实现脱卡效果
- lintcode --编辑距离
- jquery easyui Treegrid 暴力修改父节点ID