Cod sursa(job #24278)

Utilizator the1dragonIonita Alexandru the1dragon Data 1 martie 2007 23:34:53
Problema Xor Max Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<stdio.h>

long v[1024000], n, max, maxx, i, tmp;

int main()
{
	freopen("xormax.in", "r", stdin);
	freopen("xormax.out", "w", stdout);
	
	scanf("%ld", &n);
	for (i=1; i<=n; i++)
	{
		scanf("%ld", &tmp);
		v[i]=v[i-1]^tmp;
		if (v[i]>v[max]) max=i; 
	}
	maxx=max;
	for (i=1; i<=n; i++)
		if ((v[i]^v[max]) > (v[maxx]^v[max])) maxx=i;
	
	//for (i=1; i<=n; i++)
	//	printf("%ld ", v[i]);
	
	if (max>maxx)
		printf("%ld %ld %ld", v[max]^v[maxx], maxx+1, max);
	else
		printf("%ld %ld %ld", v[max]^v[maxx], max+1, maxx);
	
	return 0;
}