码迷,mamicode.com
首页 > 其他好文 > 详细

URAL 1792. Hamming Code (枚举)

时间:2015-06-09 21:56:07      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

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.
技术分享

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

input output
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原来是数字和除以二之后的余数。。。




URAL 1792. Hamming Code (枚举)

标签:

原文地址:http://blog.csdn.net/u013446688/article/details/46431509

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!