Cod sursa(job #35623)

Utilizator thestickTudor A thestick Data 22 martie 2007 11:35:34
Problema Xor Max Scor 10
Compilator c Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <stdio.h>
long n,x[100000],pmax,max,max2,pmax2,sta,sto;
void cit()
{
long i,buf,xo=0;
FILE *f;
f=fopen("xormax.in","r");
fscanf(f,"%d",&n);
for(i=0;i<n;i++)
{
fscanf(f,"%d",&buf);
xo=xo^buf;
//if(xo>max){max=xo;pmax=i;}
x[i]=xo;
}
}

void rez()
{
long tz,i,j;
max2=-1;
for(i=0;i<n-1;i++)
for(j=i;j<n;j++)
{
tz=x[j]^x[i];
if(tz>max2){max2=tz;sta=i;sto=j;}
}
}

void tip()
{
FILE *f;
f=fopen("xormax.out","w");
fprintf(f,"%d %d %d",max2,sta+2,sto+1);
}

int main()
{
cit();
rez();
tip();
return 0;
}