Report a paste

Please put a quick comment for the admin.

If it looks like spam, the admin will mark it as spam so that the spam filter picks it up in the future.

If the paste contains something private or offensive, it'll probably just be deleted.

Код Хемминга

import java.util.*;
import java.io.*;

public class Main {
    // 1 2 3 4 5
    // 1 4 3 2 5
    // 1 3 2 4 5
    // 1 3 4 2 5
    private void solve() throws IOException {
        int[] a = new int[7];
        for (int i = 0; i < 7; i++) {
            a[i] = in.nextInt();
        }
        int[] b;
        int sum1 = a[1] + a[2] + a[3];
        int sum2 = a[0] + a[2] + a[3];
        int sum3 = a[0] + a[1] + a[3];
        if (sum1 % 2 == a[4] && sum2 % 2 == a[5] && sum3 % 2 == a[6]) {
            System.out.println(a[0] + " " + a[1] + " " + a[2] + " " + a[3] + " " + a[4] + " " + a[5] + " " + a[6]);
            return;
        }
        for (int i = 0; i < 7; i++) {
            b = a.clone();
            b[i] = -1 * (b[i] - 1);
            int s1 = b[1] + b[2] + b[3];
            int s2 = b[0] + b[2] + b[3];
            int s3 = b[0] + b[1] + b[3];
            if (s1 % 2 == b[4] && s2 % 2 == b[5] && s3 % 2 == b[6]) {
                System.out.println(b[0] + " " + b[1] + " " + b[2] + " " + b[3] + " " + b[4] + " " + b[5] + " " + b[6]);
                return;
            }
        }
}

    private String filename = "";
    private PrintWriter out;
    MyScanner in;

    private void run() throws IOException {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    private class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() throws IOException {
            this.br = new BufferedReader(new InputStreamReader(System.in));
        }

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle));
        }

        public String nextLine() throws IOException {
            String s = br.readLine();
            return s == null ? "-1" : s;
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return "-1";
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public Integer nextInt() throws IOException {
            return Integer.parseInt(this.next());
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(this.next());
        }

        public Double nextDouble() throws IOException {
            return Double.parseDouble(this.next());
        }

        public void close() throws IOException {
            this.br.close();
        }
    }

    public static void main(String[] args) throws IOException{
        Locale.setDefault(Locale.US);
        new Main().run();
    }
}