Pagini recente » Cod sursa (job #660933) | Cod sursa (job #2380647) | Cod sursa (job #2779229) | Cod sursa (job #3032877) | Cod sursa (job #69653)
Cod sursa(job #69653)
#include<stdio.h>
#define v 100000
long long n,a[v],w[v],start,stop,max;
void citire()
{
freopen("xormax.in","r",stdin);
scanf("%lld", &n);
for (int i=0; i<n; i++)
scanf("%lld", &a[i]);
fclose(stdin);
}
void xormax()
{
w[0]=a[0];
start=0;
max=w[0];
stop=0;
for (int i=1; i<n; i++)
for (int j=0; j<=i; j++)
{
w[j]^=a[i];
if (w[j]>max)
{
max=w[j];
start=j+1;
stop=i+1;
}
}
}
void printare()
{
freopen("xormax.out","w",stdout);
printf("%lld %lld %lld",max,start,stop);
fclose(stdout);
}
int main()
{
citire();
xormax();
printare();
return 0;
}