Pagini recente » Cod sursa (job #1021328) | Cod sursa (job #326915) | Cod sursa (job #220409) | Cod sursa (job #2203427) | Cod sursa (job #112980)
Cod sursa(job #112980)
var nr1,dif:integer;
i,n:longint;
f,g:text;
a:array[1..65000] of byte;
begin
assign(f,'multimi2.in'); reset(f);
assign(g,'multimi2.out'); rewrite(g);
readln(f,n);
if n<65500 then begin
i:=n; dif:=0;
while i-4>=0 do begin
a[i]:=1;
a[i-1]:=2;
a[i-2]:=2;
a[i-3]:=1;
i:=i-4;
end; nr1:=(n div 4)*2;
case i of
0:dif:=0;
1:begin
a[1]:=1; dif:=1; nr1:=nr1+1; end;
2:begin
a[1]:=1; a[2]:=2; dif:=1; nr1:=nr1+1; end;
3:begin
a[1]:=1; a[2]:=1; a[3]:=2; dif:=0; nr1:=nr1+2;
end;
end;
writeln(g,dif);
writeln(g,nr1);
for i:=1 to n do
if a[i]=1 then write(g,i,' ');
writeln(g);
writeln(g,n-nr1);
for i:=1 to n do
if a[i]=2 then write(g,i,' ');
end
else begin case (n mod 4) of
0:begin dif:=0; nr1:=n div 4*2 end;
1:begin
dif:=1; nr1:=(n div 4)*2+1; end;
2:begin
nr1:=(n div 4)*2+1; end;
3:begin
dif:=0; nr1:=(n div 4)*2+2; end;
end;
writeln(g,dif);
writeln(g,nr1);
for i:=1 to nr1 do
write(g,i,' ');
writeln(g);
writeln(g,n-nr1);
for i:=(nr1+1) to n do
write(g,i,' ');
end;
end.