Cod sursa(job #24277)

Utilizator the1dragonIonita Alexandru the1dragon Data 1 martie 2007 23:26:25
Problema Xor Max Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 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; 
	}
	
	for (i=1; i<=n; i++)
		if (v[i]^v[max] > v[maxx]^v[max]) maxx=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;
}