10215 - 海明码

给出 N,B 和 D:找出 N 个编码(1 <= N <= 64),每个编码有 B 位(1 <= B <= 8),使得两两编码之间至少有 D 个单位的“海明距离”(1 <= D <= 7)。“海明距离”是指对于两个编码,他们的二进制表示法中的不同二进制位的数目。看下面的两个编码 0x554 和 0x234 之间的区别(0x554 表示一个十六进制数,每个位上分别是 5,5,4):

    0x554 = 0101 0101 0100
    0x234 = 0010 0011 0100

不同的二进制位: xxx xx

因为有五个位不同,所以“海明距离”是 5。

输入

一行,包括 N, B, D。

输出

N 个编码(用十进制表示),要排序,十个一行。如果有多解,你的程序要输出这样的解:假如把它化为 2^B 进制的数,它的值要最小。

样例

输入

16 7 3

输出

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

提示

Hamming Codes Rob Kolstad Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of length B bits (1 <= B <= 8), such that each of the codewords is at least Hamming distance of D (1 <= D <= 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 5, 5, and 4):

    0x554 = 0101 0101 0100
    0x234 = 0010 0011 0100

Bit differences: xxx xx

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

PROGRAM NAME: hamming INPUT FORMAT N, B, D on a single line

SAMPLE INPUT (file hamming.in) 16 7 3

OUTPUT FORMAT N 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 2^B integer, would have the least value.

SAMPLE OUTPUT (file hamming.out) 0 7 25 30 42 45 51 52 75 76 82 85 97 102 120 127

时间限制 1 秒
内存限制 128 MB
讨论 统计
上一题 下一题