挺简单的一道题

 /*
 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的更多相关文章

  1. 【USACO 2.1】Hamming Codes

    /* TASK: hamming LANG: C++ URL:http://train.usaco.org/usacoprob2?a=5FomsUyB0cP&S=hamming SOLVE: ...

  2. USACO 2.1 Hamming Codes

    Hamming CodesRob Kolstad Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of ...

  3. 洛谷P1461 海明码 Hamming Codes

    P1461 海明码 Hamming Codes 98通过 120提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 暂时没有讨论 题目描述 给出 N,B 和 ...

  4. 洛谷 P1461 海明码 Hamming Codes

    P1461 海明码 Hamming Codes 题目描述 给出 N,B 和 D,要求找出 N 个由0或1组成的编码(1 <= N <= 64),每个编码有 B 位(1 <= B &l ...

  5. USACO Hamming Codes DFS 构造

    我还是用了很朴素的暴力匹配A了这题,不得不感叹USACO时间放的好宽... /* ID: wushuai2 PROG: hamming LANG: C++ */ //#pragma comment(l ...

  6. USACO Section2.1 Hamming Codes 解题报告 【icedream61】

    hamming解题报告----------------------------------------------------------------------------------------- ...

  7. USACO 2.1 海明码 Hamming Codes (模拟+位运算+黑科技__builtin_popcount(n))

    题目描述 给出 N,B 和 D,要求找出 N 个由0或1组成的编码(1 <= N <= 64),每个编码有 B 位(1 <= B <= 8),使得两两编码之间至少有 D 个单位 ...

  8. USACO Hamming Codes

    题目大意:求n个两两hamming距离大于等于d的序列,每个元素是一个b bit的数 思路:仍然暴力大法好 /*{ ID:a4298442 PROB:hamming LANG:C++ } */ #in ...

  9. 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&& ...

随机推荐

  1. TF-IDF与余弦相似性的应用(三):自动摘要

    有时候,很简单的数学方法,就可以完成很复杂的任务. 这个系列的前两部分就是很好的例子.仅仅依靠统计词频,就能找出关键词和相似文章.虽然它们算不上效果最好的方法,但肯定是最简便易行的方法. 今天,依然继 ...

  2. 【Insertion Sorted List】cpp

    题目: Sort a linked list using insertion sort. 代码: /** * Definition for singly-linked list. * struct L ...

  3. window8左下角窗口和右上角窗口失效解决方法

    win8系统有时会出现任务栏和桌面点击没反应 小常识: “Windows徽标键” 这个键,左右各一个,称为“Windows徽标键”,键冒上的图案为Windows徽标,由此得名. [知识链接]位于计算机 ...

  4. ionice

    ionice – 获取或设置程序的IO调度与优先级. 命令格式: ionice [[-c class] [-n classdata] [-t]] -p PID [PID]… ionice [-c cl ...

  5. 在listener或者工具中使用spring容器中的bean实例

    在项目中经常遇见需要在Listener中或者工具中使用Spring容器中的bean实例,由于bean不能在stataic的类中使用. 介绍一种方式: public class SpringTool { ...

  6. discuz之同步登入

    前言   首先感谢dozer学长吧UCenter翻译成C# 博客地址----------->http://www.dozer.cc/   其次感谢群友快乐々止境同学的热心指导,虽然萍水相逢但让我 ...

  7. JS--传统事件模型的问题

    事件绑定分为两种情况:传统的事件绑定(内联模型.脚本模型),一种是现代事件绑定模型(DOM2级事件绑定). 内联模型的事件绑定是将事件写在元素标签中,将事件绑定函数当做元素的一种属性来实现的,这种绑定 ...

  8. offsetParent、offsetTop、offsetLeft、offsetWidth、offsetHeight

    w3c规范,请戳这里:http://www.w3.org/TR/cssom-view/#dom-htmlelement-offsetparent 一.offsetParent 英文解读: part o ...

  9. boost 相关

    编译boost: 1.打开Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prom ...

  10. Sqli-labs less 37

    Less-37 本关与34关是大致相似的,区别在于处理post内容用的是mysql_real_escape_string()函数,而不是addslashes()函数,但是原理是一直的,上面我们已经分析 ...