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.

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

时间: 2024-11-25 09:47:54

URAL 1792. Hamming Code (枚举)的相关文章

洛谷 P1461海明码 Hamming Codes 枚举 搜索

洛谷 P1461海明码 Hamming Codes枚举 搜索 1 #include <bits/stdc++.h> 2 using namespace std ; 3 4 const int N = 11 ; 5 int mx,B,n,D ; 6 int bin[N] ; 7 struct base{ 8 bool f[ N ] ; 9 inline void clear() { 10 for(int i=1;i<N;i++) f[ i ] = 0 ; 11 } 12 inline vo

[USACO][枚举]Hamming Code

题意: 给出N,B,D,要求输出N个十进制数字,他们之间的Hamming距离在长度为B位的时候都等于D. 思路: 感觉图论就是一个,允许我们记忆化的边权好工具!(废话用edges存边了还不是当然的) 代码: /* ID :ggy_7781 TASK :hamming LANG :C++11 */ #include <bits/stdc++.h> #define maxB 8 #define maxN 64 #define maxD 7 using namespace std; int N,B,

ural 1069. Prufer Code

1069. Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) with vertices is given (N ≥ 2). Vertices of the tree are numbered by the integers 1,…,N. A Prufer code for the tree is built as follows: a leaf

Hamming code

Also known as (7,4) code,7 trainsmitted bits for 4 source code. TRANSMIT The transmitted procedure can be reprecented as follows. $t=G^Ts$ where G is: import numpy as np G = np.matrix( [[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1], [1,1,1,0], [0,1,1,1]

Ural 1780 Gray Code (暴力)

Ural 1780 题意: 输入一个二进制数与该二进制数的格雷码,但有一些位置不确定,写程序将其恢复,无法恢复输出Impossible,多解输出Ambiguity. 思路: 其实是个普通的乱搞题.. Gray码的定义:Gi=Bi?1?Bi,G0=B0 (第i位格雷码等于第i位二进制码与第i-1位二进制码的异或值) 然后按照这个定义编码,正向反向各自编一遍,出现矛盾输出Impossible,最后还含有'?'则有多解. 代码: /* * @author FreeWifi_novicer * lang

Ural 1780 Gray Code 乱搞暴力

原题链接:http://acm.timus.ru/problem.aspx?space=1&num=1780 1780. Gray Code Time limit: 0.5 secondMemory limit: 64 MB Denis, Vanya and Fedya gathered at their first team training. Fedya told them that he knew the algorithm for constructing aGray code. Cre

URAL 1500. Pass Licenses 枚举+位运算

1500. Pass Licenses Time limit: 2.5 second Memory limit: 64 MB A New Russian Kolyan believes that to spend his time in traffic jams is below his dignity. This is why he had put an emergency flashlight upon the roof of his Hummer and had no problems u

枚举使用笔记

1.遍历枚举.枚举在switch case中的使用 首先创建一个常用格式的枚举类.如下,注意枚举类的构造函数不能是public的,枚举是不可变的常量的组合,如果通过公共的构造函数改变定义枚举的值,将失去枚举的意义. package enumDemo.test; public enum Season { Spring("春", 1), Summer("夏", 2), Autumn("秋", 3), Winter("冬", 4);

JAVA 如何循环枚举(main函数里)

/**  * Bestpay.com.cn Inc.  * Copyright (c) 2011-2015 All Rights Reserved.  */ package com.bestpay.bpbp.common.enums; /**  * 销账业务类型枚举  *   * @author Weiliang  * @version $Id: BizTypeEnum.java, v 0.1 2015年12月14日 下午2:20:53 Weiliang Exp $  */ public enu