Cod sursa(job #2239006)

Utilizator Raoul_16Raoul Bocancea Raoul_16 Data 8 septembrie 2018 16:57:02
Problema Xor Max Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
const std::string programName = "xormax";
std::ifstream f(programName + ".in");
std::ofstream g(programName + ".out");
const int NMAX = 1E5;
int main() {
    int N;
    f >> N;
    int v[NMAX + 5];
    for (int i = 0; i < N; ++i)
        f >> v[i];
    int S, c;
    int max(0);
    int Xcopy = 0, Xcopy2 = 0;
    int j;
    for (int i = 0; i < N; ++i) {
        S = 0;
        c = 0;
        for (j = i + 1; j < N; ++j) {
            c = v[i] ^ v[j];
            S ^= c;
        }
        if (S > max)
            max = S;
        Xcopy = j;
        Xcopy2 = i;
    }
    g << max << ' ' << Xcopy2 << ' ' << Xcopy;
    return 0x0;
}