Pagini recente » Rating cucos cococ (dorinc) | Cod sursa (job #411031) | Cod sursa (job #2356698) | Cod sursa (job #2942138) | Cod sursa (job #176703)
Cod sursa(job #176703)
const modulo=1048575;
var a:array[0..3] of longint;
f,g:text;
i,n:longint;
begin
assign(f,'12perm.in'); reset(f);
assign(g,'12perm.out'); rewrite(g);
read(f,n);
a[0]:=1; a[1]:=2; a[2]:=6; a[3]:=12; //a[4] a[5] a[6] a[7]
for i:=5 to n do begin
case i and 3 of
1: a[0]:=(a[3]+a[1]+(i-2) shl 1) and modulo;
2: a[1]:=(a[0]+a[2]+(i-2) shl 1) and modulo;
3: a[2]:=(a[1]+a[3]+(i-2) shl 1) and modulo;
0: a[3]:=(a[2]+a[0]+(i-2) shl 1) and modulo;
end;
end;
if n<=4 then
writeln(g,a[n])
else begin
case i and 3 of
1: writeln(g,a[0]);
2: writeln(g,a[1]);
3: writeln(g,a[2]);
0: writeln(g,a[3]);
end;
end;
close(f); close(g);
end.