Pagini recente » Cod sursa (job #1507448) | Cod sursa (job #635727) | Cod sursa (job #88099) | Cod sursa (job #916854) | Cod sursa (job #275502)
Cod sursa(job #275502)
// xor max.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
char c[900001];
int e[100001];
void parsare()
{
int i,nr=1,x=0;
fgets(c,900000,stdin);
for(i=0;c[i];i++)
if(c[i]==' ')
{
e[nr++]=x;
x=0;
}
else
x=10*x+c[i]-'0';
e[nr]=x;
}
int main()
{
freopen("xormax.in","r",stdin);
freopen("xormax.out","w",stdout);
int n,maxim=0,start=1,stop=1,i,j,curent;
scanf("%d\n",&n);
parsare();
for(i=1;i<=n;i++)
{
curent=e[i];
if(curent>maxim)
{
maxim=curent;
start=i;
stop=i;
}
for(j=i+1;j<=n;j++)
{
curent=curent^e[j];
if(curent>maxim)
{
maxim=curent;
start=i;
stop=j;
}
}
}
printf("%d %d %d",maxim,start,stop);
return 0;
}