Cod sursa(job #1640207)

Utilizator SburlyAndrei Florin Sburly Data 8 martie 2016 16:24:08
Problema Xor Max Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;

    ifstream f("xormax.in");
    ofstream g("xormax.out");

    int n, b, e;
    f >> n;
    long int v[n];

    for(int i = 0; i < n; i++)
    {
        f >> v[i];
    }
    long int mx = -1;
    for(int i = 1; i < n; i++)
    {
        long int x = v[i];
        for(int j = i-1; j >= 0; j--)
        {
            x ^= v[j];
            if(x > mx)
            {
                e = i;
                b = j;
                mx = x;
            }
        }
    }
    g << mx << ' ' << b+1 << ' ' << e+1;
    return 0;
}