Cod sursa(job #583315)

Utilizator gicu_01porcescu gicu gicu_01 Data 19 aprilie 2011 17:04:09
Problema Xor Max Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.63 kb
var a:array[1..100000]of longint;
    n:longint;
procedure init;
var i:longint;f:text;
begin
 assign(f,'xormax.in');
 reset(f);
 readln(n);
 for i:=1 to n do read(f,a[i]);
 close(f);
end;

function asdf(x,y:longint):longint;
var i,k:longint;
begin
 k:=x;
 for i:=x+1 to y do k:=k or a[i];
 asdf:=k;
end;

procedure calc;
var i,j,max,x,y,k:longint; f:text;
begin
 assign(f,'xormax.out');
 rewrite(f);
 max:=asdf(1,1); x:=1; y:=1;
 for i:=1 to n do
  for j:=i to n do
   begin
    if max<asdf(i,j) then begin max:=k; x:=i; y:=j; end;
   end;
  writeln(f,max,x,y);
 close(f);
end;

begin
 init;
 calc;
end.