Cod sursa(job #340741)

Utilizator doruletzPetrican Teodor doruletz Data 16 august 2009 13:52:06
Problema Multimi2 Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.91 kb
program multimi2;
var i,n,nr1,nr2:0..1000000;
    a,b:array[0..500000]of 0..1000000;
    dif:0..2;
    cont:0..4;
    t:text;

procedure scrie;
begin
 assign(t,'multimi2.out'); rewrite(t);
  writeln(t,dif);
  writeln(t,nr1);
  for i:=1 to nr1 do write(t,a[i],' ');
  writeln(t);
  writeln(t,nr2);
  for i:=1 to nr2 do write(t,b[i],' ');
 close(t);
end;

begin
 assign(t,'multimi2.in'); reset(t);
  readln(t,n);
 close(t);

 dif:=0;
 if (n mod 4)=1 then begin inc(nr1); a[nr1]:=1; dif:=1 end;
 if (n mod 4)=2 then begin inc(nr1); inc(nr2); a[nr1]:=1; b[nr2]:=2; dif:=1; end;
 if (n mod 4)=3 then begin inc(nr1); a[nr1]:=1; inc(nr1); a[nr1]:=2; inc(nr2); b[nr2]:=3; dif:=0; end;

 for i:=(n mod 4) to n do begin
  inc(cont);
  if cont=1 then begin inc(nr1); a[nr1]:=i; end else
   if cont=4 then begin cont:=0; inc(nr1); a[nr1]:=i; end else begin inc(nr2); b[nr2]:=i; end;
 end;

 scrie;
end.