ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1319. Hotel

This is my very simple solution in Pacal!
Posted by NikolaV994 26 Nov 2011 22:05
program Project2;
var a:array[1..100,1..100] of integer;
    k,p,n,i,j,s:integer;
begin
      readln(n);
      k:=0;
      p:=n-1;
      for s:=1 to (n*2-1) do begin
                                  for i:=1 to n do for j:=1 to n do if j-i=p then begin
                                                                                       k:=k+1;
                                                                                       a[i,j]:=k
                                                                                  end;
                                  p:=p-1
                              end;
      for i:=1 to n do begin
                            for j:=1 to n do begin
                                                  write(a[i,j]);
                                                  write(' ')
                                             end;
                            writeln
                       end;
end.