Identificatorul de task este invalid
Cod sursa(job #69653)
| Utilizator | Data | 3 iulie 2007 20:06:15 | |
|---|---|---|---|
| Problema | Xor Max | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#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;
}
