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&& ...
随机推荐
- UBOOT分析
U-Boot是一个通用的Boootloader,它是在系统上电后执行的第一段程序,先初始化硬件设备,再准备软件环境,最后引导系统内核. 一般来说Bootloader的启动过程来说一般分两个阶段: 第一 ...
- ACK
ACK (Acknowledgement),即确认字符,在数据通信中,接收站发给发送站的一种传输类控制字符.表示发来的数据已确认接收无误. 目录 1基本介绍 2详细释义 1基本介绍编辑 英文缩 ...
- Entity Framework公共的增删改方法
using System; using System.Collections.Generic; using System.Data.Entity; using System.Data.Entity.I ...
- Leetcode#89 Gray Code
原题地址 二进制码 -> 格雷码:从最右边起,依次与左边相邻位异或,最左边一位不变.例如: 二进制: 1 0 0 1 1 1 0 |\|\|\|\|\|\| 格雷码: 1 1 0 1 0 0 1 ...
- webservice之XFire的使用(java调用java)
注意:xfire不支持java.util.List等集合,所以调用webservice传递的参数要为基本类型. 转自:http://zp9245.blog.163.com/blog/static/10 ...
- JavaScript之Throw、Try 、Catch讲解
try 语句测试代码块的错误. catch 语句处理错误. throw 语句创建自定义错误. 错误一定会发生 当 JavaScript 引擎执行 JavaScript 代码时,会发生各种错误: 可能是 ...
- Sqli-labs less 65
Less-65 $id = '"'.$id.'"'; // Querry DB to get the correct output $sql="SELECT * FROM ...
- 编写更好的CSS
编写好的CSS代码能提升页面的渲染速度.本质上,一条规则都没有引擎解析的最快.MDN上将CSS选择符归拆分成四个主要类别,如下所示,性能依次降低. ID 规则 Class 规则 标签规则 通用规则 对 ...
- 还是说Memory Model,gcc的__sync_synchronize真是太坑爹了
还是说Memory Model,gcc的__sync_synchronize真是太坑爹了! 时间 2012-01-29 03:18:35 IT牛人博客聚合网站 原文 http://www.udpw ...
- python 安装 管理包 pip
2.7的坑里出不来了,现在已经换到3.4了,不存在下列问题. win7下安装pip http://blog.chinaunix.net/uid-24984661-id-4202194.html ...