您的位置:首页 > 其它

URAL 1792. Hamming Code (枚举)

2015-06-09 21:08 357 查看

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

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原来是数字和除以二之后的余数。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: