Cod sursa(job #35585)
Utilizator | Data | 22 martie 2007 11:01:12 | |
---|---|---|---|
Problema | Xor Max | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <stdio.h>
long n,x[100000],pmax,max,max2,pmax2;
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;
pmax2=-1;
for(i=0;i<n;i++)
{
tz=max^x[i];
if(tz>max2){max2=tz;pmax2=i;}
}
}
void tip()
{
FILE *f;
f=fopen("xormax.out","w");
fprintf(f,"%d %d %d",max2,pmax+2,pmax2+1);
}
int main()
{
cit();
rez();
tip();
return 0;
}