#P1461. [USACO2.1] Hamming Codes

[USACO2.1] Hamming Codes

题目描述

Given NN, BB, and DD, find a set of NN codewords (1N641 \le N \le 64), each of length BB bits (1B81 \le B \le 8), such that each of the codewords is at least Hamming distance DD (1D71 \le D \le 7) away from each of the other codewords.

The Hamming distance between a pair of codewords is the number of binary bits that differ in their binary notation. Consider the two codewords 0x554 and 0x234 and their differences. 0x554 means the hexadecimal number with hex digits 55, 55, and 44, and a hex digit requires four bits:

           0x554 = 0101 0101 0100
           0x234 = 0010 0011 0100
Bit differences:   -XXX -XX- ----

Since five bits were different, the Hamming distance is 55.

输入格式

NN, BB, DD on a single line.

输出格式

NN codewords, sorted, in decimal, ten per line. In the case of multiple solutions, your program should output the solution which, if interpreted as a base 2B2^B integer, would have the least value.

16 7 3
0 7 25 30 42 45 51 52 75 76
82 85 97 102 120 127

提示

USACO Training Section 2.1