Pagini recente » Cod sursa (job #987010) | Cod sursa (job #2347466) | Cod sursa (job #1937295) | Cod sursa (job #936189) | Cod sursa (job #113425)
Cod sursa(job #113425)
#include <stdio.h>
#define Nmax 100001
long c[Nmax], p, u, max, temp, rezX, rezY, aux;
long n, i;
int main()
{
freopen("xormax.in", "r", stdin);
scanf("%ld\n", &n);
for (i=1; i<=n; i++) scanf("%ld ", &c[i]);
max=temp=c[1];
p=u=rezX=rezY=1;
for (i=2; i<=n; i++)
{
aux=temp | c[i];
if (aux > c[i])
{
u++;
temp=aux;
}
else
{
p=u=i;
temp=c[i];
}
if (temp>max || (temp==max && u-p<rezY-rezX))
{
max=temp;
rezX=p;
rezY=u;
}
}
fclose(stdin);
freopen("xormax.out", "w", stdout);
printf("%ld %ld %ld", max, rezX, rezY);
fclose(stdout);
return 0;
}