Pagini recente » Cod sursa (job #352137) | Cod sursa (job #755969) | Cod sursa (job #104911) | Cod sursa (job #395328) | Cod sursa (job #113422)
Cod sursa(job #113422)
#include <stdio.h>
#define Nmax 1001
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;
}