codeforces 467B Fedor and New Game 解题报告
题目链接:http://codeforces.com/contest/467/problem/B
题目意思:有 m + 1 个 player 和 n 种类型的 soldiers。每个player被赋予一个数xi,然后将xi 看成二进制数,规定第 j 位 如果为1,表示这个 player 有j 这种类型的soldiers。Fedor 是 第 m + 1 个player,问他能跟前面 m 个players 成为 friends 的 人数。成为friends 的条件是被比较的两个人的不同soldiers数不得多于 k 个。
好容易想到方法,就是异或之后统计1的个数。不过数组开小了,被人 hack !而且比赛时间只有一小时,校园网断网!有进步的是,有时间做了下C,虽然是错掉了。
太粗心了,留个纪念吧~~~
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std; const int maxn = + ;
int a[maxn]; int main()
{
int n, m, k;
while (scanf("%d%d%d", &n, &m, &k) != EOF)
{
for (int i = ; i < m; i++)
scanf("%d", &a[i]);
scanf("%d", &a[m]);
int ans = ;
for (int i = ; i < m; i++)
{
int tmp = a[i] ^ a[m];
int cnt = ;
for (; tmp; tmp >>= )
{
if (tmp & )
cnt++;
}
if (cnt <= k)
ans++;
}
printf("%d\n", ans);
}
return ;
}
codeforces 467B Fedor and New Game 解题报告的更多相关文章
- codeforces C1. The Great Julya Calendar 解题报告
题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...
- codeforces B. Eugeny and Play List 解题报告
题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...
- codeforces 433C. Ryouko's Memory Note 解题报告
题目链接:http://codeforces.com/problemset/problem/433/C 题目意思:一本书有 n 页,每页的编号依次从 1 到 n 编排.如果从页 x 翻到页 y,那么| ...
- codeforces 556B. Case of Fake Numbers 解题报告
题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每 ...
- codeforces 510B. Fox And Two Dots 解题报告
题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...
- codeforces 505A. Mr. Kitayuta's Gift 解题报告
题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母 ...
- codeforces 499A.Inna and Pink Pony 解题报告
题目链接:http://codeforces.com/problemset/problem/499/A 题目意思:有两种按钮:1.如果当前观看的时间是 t,player 可以自动处理下一分钟,姑且理解 ...
- codeforces 374A Inna and Pink Pony 解题报告
题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行 m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动 ...
- codeforces 471B. MUH and Important Things 解题报告
题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...
随机推荐
- MyBatis的一级缓存和二级缓存
一级缓存 是SqlSession级别的缓存,当使用了clearCache方法和,或者close方法的话,这个缓存失效,如果还有同样的查询,则还会发送一次查询 SqlSession session = ...
- 词典对象(NSDictionary和NSMutableDictionary)
词典(dictionary)顾名思义就是同由键-值组成的数据集合.与在词典中查找单词定义一样,可以通过对象的键从词典中获取需要的对象,看到 这里,你是不是想起了java中的map?和NSArray一样 ...
- Android Studio 删除项目
在项目上右键 点击“Open Module Settings”,然后你会看到你的项目排成一列,如果想删除哪个,点击项目,然后在左上角,点击“-”号,然后返回后发现这个项目变为灰色,点击项目右键,看到“ ...
- 【Jpa hibernate】一对多@OneToMany,多对一@ManyToOne的使用
项目中使用实体之间存在一对多@OneToMany,多对一@ManyToOne的映射关系,怎么设置呢? GitHub地址:https://github.com/AngelSXD/myagenorderd ...
- UITableViewCell -- 动画
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath: ...
- SilverLight-DataBinding:二、Bingding to a Collection Objects(绑定一个集合对象)
ylbtech-SilverLight-DataBinding: Bingding to a Collection Objects(绑定一个集合对象) 1.A, Building a Data Ob ...
- live555client连多路1080P视频流花屏问题
硬件和软件环境是这种: DM8168 + linux. 解码器是DM8168自带的 视频来源: ipc通过live555做的的rtsp sever发送过来的 其它測试: 通过VLC在pc连4路1080 ...
- UVA571 - Jugs(数论)
UVA571 - Jugs(数论) 题目链接 题目大意:给你A和B的水杯.给你三种操作:fill X:把X杯里面加满水.empty X:把X杯中的水清空.pour X Y 把X的水倒入Y中直到一方满或 ...
- 自己写的通过ADO操作mysql数据库
#include <iostream> #include <windows.h> #include <atlstr.h> #import "c:\Prog ...
- odoo生产物流
odoo生产从raw materials location 自动消耗物料,产成品进入到finish productslocation. 而odoo自动产生的MO[manufacture Order], ...