USACO Section 2.1: Hamming Codes
挺简单的一道题
/*
ID: yingzho1
LANG: C++
TASK: hamming
*/
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <cstring>
using namespace std;
ifstream fin("hamming.in");
ofstream fout("hamming.out");
int N, B, D;
int hamming(int l, int r) {
int tmp = l ^ r;
;
while (tmp) {
) ret++;
tmp >>= ;
}
return ret;
}
int main()
{
fin >> N >> B >> D;
;
vector<int> words;
words.push_back();
; num < ( << B); num++) {
if (acount == N) break;
;
for (; j < words.size(); j++) {
if (hamming(num, words[j]) < D) break;
}
if (j == words.size()) {
words.push_back(num);
acount++;
}
}
; i < N; i++) {
fout << words[i];
!= && i != N-) fout << " ";
else fout << endl;
}
;
}
USACO Section 2.1: Hamming Codes的更多相关文章
- 【USACO 2.1】Hamming Codes
/* TASK: hamming LANG: C++ URL:http://train.usaco.org/usacoprob2?a=5FomsUyB0cP&S=hamming SOLVE: ...
- USACO 2.1 Hamming Codes
Hamming CodesRob Kolstad Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of ...
- 洛谷P1461 海明码 Hamming Codes
P1461 海明码 Hamming Codes 98通过 120提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 暂时没有讨论 题目描述 给出 N,B 和 ...
- 洛谷 P1461 海明码 Hamming Codes
P1461 海明码 Hamming Codes 题目描述 给出 N,B 和 D,要求找出 N 个由0或1组成的编码(1 <= N <= 64),每个编码有 B 位(1 <= B &l ...
- USACO Hamming Codes DFS 构造
我还是用了很朴素的暴力匹配A了这题,不得不感叹USACO时间放的好宽... /* ID: wushuai2 PROG: hamming LANG: C++ */ //#pragma comment(l ...
- USACO Section2.1 Hamming Codes 解题报告 【icedream61】
hamming解题报告----------------------------------------------------------------------------------------- ...
- USACO 2.1 海明码 Hamming Codes (模拟+位运算+黑科技__builtin_popcount(n))
题目描述 给出 N,B 和 D,要求找出 N 个由0或1组成的编码(1 <= N <= 64),每个编码有 B 位(1 <= B <= 8),使得两两编码之间至少有 D 个单位 ...
- USACO Hamming Codes
题目大意:求n个两两hamming距离大于等于d的序列,每个元素是一个b bit的数 思路:仍然暴力大法好 /*{ ID:a4298442 PROB:hamming LANG:C++ } */ #in ...
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
随机推荐
- Eclipse的python插件安装
网上找了一些资料都没有成功~~然后自己装的过程中编辑记录了一些 当然博客园里也有人用这一种方法也可以参考IBM中的 http://www.cnblogs.com/visec479/p/4139882. ...
- Gentoo 网络接口配置文件说明
裁剪的Gentoo系统,仅供公司内部使用! [作为备份档案] 网络接口配置:/etc/conf.d/net #设置静态IPconfig_eth0="192.168.1.x/24" ...
- 运用.NIT将数据存入数据库、读取数据库(运用封装)陈老师作业
我基础不好,根据所学的知识,书本的例题修改的,也不知道我理解的是否符合老师要求 运用C#将数据存入数据库.并且可以读取数据库里的数据,此项目我运用了封装.我运用了一个窗体将数据存读数据. 我首先创建了 ...
- Matlab梯度下降解决评分矩阵分解
for iter = 1:num_iters %梯度下降 用户向量 for i = 1:m %返回有0有1 是逻辑值 ratedIndex1 = R_training(i,:)~=0 ; %U(i,: ...
- 重启nginx后丢失nginx.pid解决
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- Hadoop伪分布模式配置
本作品由Man_华创作,采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可.基于http://www.cnblogs.com/manhua/上的作品创作. 请先按照上一篇文章H ...
- 寒假222_Topcoder SRM648
序号1: A,随便模拟好了,最后30秒发现一个都比的错误,无奈输错格式. 2: B,问你出去两个点,以及所产生的边 问你:产生多的联通快 加答案加1. 数据小,随便写暴力 3: copy思路. 我们先 ...
- JS读取client端的文件的代码片段
JS读取client端的文件内容的代码片段 if(window.FileReader){ var html5file = this.pipeDetailFileUpLoader._files[0]; ...
- ISIN编码
国际证券识别编码(ISIN编码)是由国际标准化组织(ISO)制定的证券编码标准,并在<证券及相关金融工具-国际证券识别编码体系>(ISO6166)中正式发布.ISO6166主要规定了ISI ...
- hadoop开发环境-----eclipse
1.eclipse下载 http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr1 2.hadoo ...