题目链接: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 解题报告的更多相关文章

  1. codeforces C1. The Great Julya Calendar 解题报告

    题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...

  2. codeforces B. Eugeny and Play List 解题报告

    题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...

  3. codeforces 433C. Ryouko's Memory Note 解题报告

    题目链接:http://codeforces.com/problemset/problem/433/C 题目意思:一本书有 n 页,每页的编号依次从 1 到 n 编排.如果从页 x 翻到页 y,那么| ...

  4. codeforces 556B. Case of Fake Numbers 解题报告

    题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每 ...

  5. codeforces 510B. Fox And Two Dots 解题报告

    题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...

  6. codeforces 505A. Mr. Kitayuta's Gift 解题报告

    题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母 ...

  7. codeforces 499A.Inna and Pink Pony 解题报告

    题目链接:http://codeforces.com/problemset/problem/499/A 题目意思:有两种按钮:1.如果当前观看的时间是 t,player 可以自动处理下一分钟,姑且理解 ...

  8. codeforces 374A Inna and Pink Pony 解题报告

    题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行  m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动 ...

  9. codeforces 471B. MUH and Important Things 解题报告

    题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...

随机推荐

  1. Kalendae使用总结

    2019-03-06 16:50:18 git官方教程:https://github.com/Twipped/Kalendae js.css:https://pan.baidu.com/s/1Ye-d ...

  2. Java获取指定时间(转)

    说明:从LocalDate的API上看,主要用于快速获取当前年月日,而DateFormatter也基本上伴随着使用.如果是操作Date对象的,主要是用于时间戳等,伴随着使用的是SimpleDateFo ...

  3. Bitmap 图片格式并用 C++ 读写 Bitmap

    转自 Bitmap 图片格式并用 C++ 读写 Bitmap 1.Bitmap 图片格式 每部分的具体内容就不展开了.要说的有两点: (1)调色板不是必须的,可有可无,有没有调色板可以通过位图文件头的 ...

  4. repeated-substring-pattern

    https://leetcode.com/problems/repeated-substring-pattern/ 下面这个方法,开始我觉得挺好.可惜还是超时了.后来我就加了一个剪枝策略,只有长度能够 ...

  5. Android开源工具项目集合

    最近因为要去外派了,工欲善其事,必先利其器!所以又回顾了一下自己github上所收藏的项目,也算是温故而知新吧. 最流行的Android组件大全 http://www.open-open.com/li ...

  6. GDB调试多线程程序

    gdb有thread相关命令,如info thread(简写成info th)显示线程消息,b xx thread yy可以针对某个thread设置断点,thread xx(简写成thr xx)切换到 ...

  7. Swagger学习和实践

    Swagger学习和实践 学习了:https://www.cnblogs.com/zxtceq/p/5530396.html swagger 英 [ˈswægə(r)] 美 [ˈswæɡɚ] vi.昂 ...

  8. [Algorithms] Sort an Array with a Nested for Loop using Insertion Sort in JavaScript

    nsertion sort is another sorting algorithm that closely resembles how we might sort items in the phy ...

  9. HDU 1418 抱歉 (欧拉公式)

    [题目链接]:pid=1418">click here~~ [题目大意]: 假设平面上有n个点,而且每一个点至少有2条曲线段和它相连,就是说,每条曲线都是封闭的.同一时候,我们规定: ...

  10. Scrapy爬虫入门系列1 安装

    安装python2.7 参见CentOS升级python 2.6到2.7 安装pip 参见CentOS安装python setuptools and pip‎ 依赖 https://docs.scra ...