Cod sursa(job #1806013)

Utilizator robertpop99Popescu Robert Gabriel robertpop99 Data 14 noiembrie 2016 19:15:41
Problema Xor Max Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
#define Nmax 100001
using namespace std;
long n,v[Nmax],imax,kmax;
long long x,xmax=0;
int main()
{   ifstream f("xormax.in");
    ofstream g("xormax.out");
    long i,k;
    f>>n;
    for(i=1;i<=n;i++)
        f>>v[i];
    for(i=1;i<n;i++)
       {
           x=v[i];
        for(k=1;k<=n-i;k++)
    {   x=x^v[i+k];
        if(x>xmax)
        {
            xmax=x;
            imax=i;
            kmax=k;
        }
    }
    }
    g<<xmax<<' '<<imax<<' '<<imax+kmax<<endl;
    return 0;
}