Page 140 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 140

100 Problems & Solutions                                               Trang 140


                      type         MG  =array[1..5,1..5] of byte;
                      var           a  : array[1..N,1..N] of integer;
                                      w : array[1..600] of MG;
                                      d  : array[1..5] of integer;
                                      c,dong,cc,ddd : array[0..N] of integer;
                                      ok : boolean;
                                      dem,sl : longint;
                                      s : MG;
                                      f : text;
                      procedure nap;
                      var i,j,k  : integer;
                       begin
                         for i:=1 to 5 do
                           begin
                             k:=0;
                             inc(dem);
                             for j:=1 to 5 do
                              if i<>j then
                                begin
                                  inc(k);
                                  w[dem,j]:=s[k];
                                end;
                           end;
                       end;

                      procedure try(i:byte);
                      var j :byte;
                       begin
                         for j:=1 to 5 do
                          if d[j]=0 then
                            begin
                              s[i,j]:=1;
                              d[j]:=1;
                              if i=4 then nap
                               else try(i+1);
                              d[j]:=0;
                              s[i,j]:=0;
                            end;
                       end;
                      procedure kiemtra;
                      var i,j,use,k   :integer;
                       begin
                         cc:=c;
                         for i:=1 to 5 do
                          for j:=1 to N do dec(cc[j],a[dong[i],j]);
                         use:=0;
                         for k:=1 to N do inc(use,ord(cc[k]>0));
                         if use<=5 then ok:=false;
                       end;
                      procedure thu(i:integer);



                      Tin học & Nhà trường                                       100 Đề Toán - Tin học
   135   136   137   138   139   140   141   142   143   144   145