Cod sursa(job #779253)

Utilizator t.g.g.tt.g.g.t t.g.g.t Data 17 august 2012 11:36:07
Problema Indep Scor 5
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.52 kb
var a:array[1..501]of integer;  n,i,j,c,b,r:integer; s:qword;
begin
assign(input,'indep.in'); reset(input);
readln(n);
for i:=1 to n do readln(a[i]);
s:=0;
assign(output,'indep.out'); rewrite(output);
for i:=1 to n do
  for j:=i+1 to n do
    begin
      if a[i]>a[j] then begin c:=a[i]; b:=a[j] end else begin c:=a[j]; b:=a[i] end;
      r:=0;
      repeat
        r:= c mod b;
        c:=b;
        b:=r;
      until r=0;
      if c=1 then s:=s+((1 shl (n-j+1)) div 2);
    end;
writeln(s);
close(output);
end.