URAL 1792. Hamming Code (枚举)

本文介绍了一种称为汉明码的纠错编码方案,并详细解释了如何通过修改最多一个位来纠正输入集中的错误。文章还提供了一个具体的示例,展示了如何计算花瓣上的值并确定哪些位可能发生了改变。

1792. Hamming Code

Time limit: 1.0 second
Memory limit: 64 MB
Let us consider four disks intersecting as in the figure. Each of the three shapes formed by the intersectionof three disks will be called a petal.
Write zero or one on each of the disks. Then write on each petal the remainder in the division by two of the sumof integers on the disks that contain this petal. For example, if there were the integers 0, 1, 0, and 1 writtenon the disks, then the integers written on the petals will be 0, 1, and 0 (the disks and petals are given in theorder shown in the figure).
This scheme is called a Hamming code. It has an interesting property: if you enemy changes secretely anyof the seven integers, you can determine uniquely which integer has been changed. Solve this problem and you willknow how this can be done.
Problem illustration

Input

The only line contains seven integers separated with a space, each of them being zero or one. The first fourintegers are those written on the disks in the order shown in the figure. The following three integers are thosewritten on the petals in the order shown in the figure

Output

Output one line containing seven integers separated with a space. The integers must form a Hamming code. The setof integers may differ from the input set by one integer at most. It is guaranteed that either the input set isa Hamming code or a Hamming code can be obtained from it by changing exactly one integer.

Samples

inputoutput
0 1 0 1 1 0 1
0 1 0 0 1 0 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
Problem Author: Sofia Tekhazheva, prepared by Olga Soboleva
Problem Source: Ural Regional School Programming Contest 2010



解析:直接枚举哪个数字错了就可以,可是要注意错误数字最多仅仅可能是一个。!

PS:開始看到Hamming Code,还以为看到了计组的题。。。结果看了半天题目没看懂。

。。the remainder in the division by two of the sum of integers原来是数字和除以二之后的余数。

。。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值