Cod sursa(job #742407)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 29 aprilie 2012 23:28:11
Problema 12-Perm Scor 5
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.32 kb
Program perm12;
const md=1048575;
 var n,a,b,c,i,d:longint;
     fi,fo:text;
begin
 assign(fi,'12perm.in');
  assign(fo,'12perm.out');
 reset(fi); rewrite(fo); readln(fi,n);
 a:=2; b:=6; c:=12;
   for i:=5 to n do begin d:=c; c:=(c+a+(i-2)*2); if c>=md then c:=c-md; a:=b; b:=d; end;
  write(fo,c);
 close(fo);
end.