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 都有一定的难度值来评估 ...
随机推荐
- Jenkins-------初探
Jenkins 安装和使用就不说了,说一下jenkins mail的配置,稍微有点坑,记住两个地址一致 插件安装时也出问题,大天朝的防火墙真是醉了,如下 更换我大天朝的镜像站 链接如下 ht ...
- SVG动画实践篇-音量变化效果
git 地址:https://github.com/rainnaZR/svg-animations/tree/master/src/pages/step2/volumn 说明 这个动画的效果就是多个线 ...
- git学习五:eclipse使用git下载项目
原文:http://blog.csdn.net/u014079773/article/details/51597213 准备工作: 目的:从远程仓库github上down所需的项目 eclipse使用 ...
- iOS开发 绘图详解
Quartz概述 Quartz是Mac OS X的Darwin核心之上的绘图层,有时候也认为是CoreGraphics.共有两种部分组成 Quartz Compositor,合成视窗系统,管理和合 ...
- yii框架:CDbConnection failed to open the DB connection: could not find driver的解决的方法
这个问题是由于php中缺少pdo mysql造成的. 解决方法是为php加入此扩展.前往你最早的php安装文件,进入ext/pdo_mysql/文件夹下,然后./configure --with-ph ...
- intent 支持的action 动作
String ACTION_AIRPLANE_MODE_CHANGED Broadcast Action: The user has switched the phone into or out of ...
- 利用 apache ab 测试服务器性能
安装步骤:https://blog.csdn.net/ahaaaaa/article/details/51514175 在Windows系统下,打开cmd命令行窗口,定位到apache安装目录的bin ...
- 合并SO为单独交货单
本场景为单步交货 为客户建立专用的route. 增加一个pull rule 在做订单的时候,为订单行选择 上面建立好的route, 连续建立了 2个 订单 SO ...
- 关于finfo_file函数获取文件mime值验证出错的问题
今天在做图片上传 验证图片mime值时 突然发现 个别特殊情况下finfo_file 获取的MIME值不能直接使用, 依照官方的写法是 $finfo=finfo_open(FILEINFO_MIME ...
- web微信开发
群里接收消息时,使用广播,但需要刷新页面才能接收到广播内容. - 轮询: 定时每秒刷新一次,当群不活跃时,群里的每个客户端都在刷新,对服务端压力太大. - 长轮询:客户端连服务端,服务端一直不断开,也 ...