Cod sursa(job #769745)
Utilizator | t.g.g.t t.g.g.t | Data | 20 iulie 2012 17:12:07 |
---|---|---|---|
Problema | 12-Perm | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
const modul=1048575;
var i,a,b,c,n,s:longint;
begin
assign(input,'12perm.in'); reset(input);
read(n); s:=0; a:=2; b:=6; c:=12;
for i:=5 to n do begin s:=(c+a+2*(i-2)) and modul; a:=b; b:=c; c:=s; end;
if n=1 then s:=1 else if n=2 then s:=2 else if n=3 then s:=6 else if n=4 then s:=12;
assign(output,'12perm.out'); rewrite(output);
writeln(s);
close(output);
end.