Pagini recente » Cod sursa (job #50780) | Cod sursa (job #2512110) | Cod sursa (job #2087620) | Cod sursa (job #754078) | Cod sursa (job #113423)
Cod sursa(job #113423)
#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)
{
max=temp;
rezX=p;
rezY=u;
}
}
fclose(stdin);
freopen("xormax.out", "w", stdout);
printf("%ld %ld %ld", max, rezX, rezY);
fclose(stdout);
return 0;
}