Cod sursa(job #463915)

Utilizator 05_YohnE1 La5c01 05_Yohn Data 17 iunie 2010 22:31:25
Problema Lacate Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.76 kb
var v:array[1..100,1..100]of integer;
w:array[1..100]of byte;
n,i,j:byte;
l,c:integer;
begin
assign(input,'lacate.in');reset(input);
assign(output,'lacate.out');  rewrite(output);
read(n);
writeln(n*(n-1) shr 1,' ',n-1);
c:=1; l:=n*(n-1)shr 1;
for i:=1 to n do begin
    for j:=1 to n-1 do begin
        v[i,j]:=c;
        inc(w[c]);
        inc(c);
        while ((w[c]=2)or(c>l))and((i<>n)or(j<>n-1)) do begin
              inc(c);
              if c>l then c:=1;
              end;
        end;
    c:=v[i,1]+1;
    if c>l then c:=1;
    while (w[c]=2)and(i<>n) do begin
          inc(c);
          if c>l then c:=1;
          end;
end;

for i:=1 to n do begin
    for j:=1 to n-1 do write(v[i,j],' ');
    writeln;
end;
close(output);
end.