Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- ikl = 64;
- type
- pole = record
- x: integer;
- y: integer;
- end;
- type
- mas = array[1..ikl]of pole;
- function obx(tek1: pole; proi: mas; sh: integer): boolean;
- var
- i: integer;
- tested: boolean;
- begin
- tested := true;
- for i := 1 to sh do
- begin
- if (proi[i].x = tek1.x) and (proi[i].y = tek1.y) then
- tested := false;
- end;
- obx := tested;
- end;
- function shaq(tek, fin: pole; proi: mas; colv, sh: integer): integer;
- var
- sum: integer;
- tek1: pole;
- begin
- sum := 0;
- if (tek.x = fin.x) and (tek.y = fin.y) then
- sum := 1
- else
- begin
- if colv > 0 then
- begin
- proi[sh] := tek;
- if tek.x + 2 <= 8 then
- begin
- if tek.y + 1 <= 8 then
- begin
- tek1.x := tek.x + 2;
- tek1.y := tek.y + 1;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- if tek.y - 1 >= 1 then
- begin
- tek1.x := tek.x + 2;
- tek1.y := tek.y - 1;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- end;
- if tek.x - 2 >= 1 then
- begin
- if tek.y + 1 <= 8 then
- begin
- tek1.x := tek.x - 2;
- tek1.y := tek.y + 1;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- if tek.y - 1 >= 1 then
- begin
- tek1.x := tek.x - 2;
- tek1.y := tek.y - 1;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- end;
- if tek.y + 2 <= 8 then
- begin
- if tek.x + 1 <= 8 then
- begin
- tek1.x := tek.x + 1;
- tek1.y := tek.y + 2;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- if tek.x - 1 >= 1 then
- begin
- tek1.x := tek.x - 1;
- tek1.y := tek.y + 2;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- end;
- if tek.y - 2 >= 1 then
- begin
- if tek.x + 1 <= 8 then
- begin
- tek1.x := tek.x + 1;
- tek1.y := tek.y - 2;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- if tek.x - 1 >= 1 then
- begin
- tek1.x := tek.x - 1;
- tek1.y := tek.y - 2;
- if obx(tek1, proi, sh) then
- sum := sum + shaq(tek1, fin, proi, colv - 1, sh + 1);
- end;
- end;
- end;
- end;
- shaq := sum;
- end;
- var
- proi: mas;
- s, s1, alf: string;
- star, fin: pole;
- colv, colvsha, code: integer;
- begin
- alf := 'ABCDEFGH';
- readln(s);
- s1 := copy(s, 1, pos(' ', s) - 1);
- delete(s, 1, pos(' ', s));
- star.x := pos(copy(s1, 1, 1), alf);
- val(copy(s1,2,1), star.y, code);
- s1 := copy(s, 1, pos(' ', s) - 1);
- delete(s, 1, pos(' ', s));
- fin.x := pos(copy(s1, 1, 1), alf);
- val(copy(s1,2,1), fin.y, code);
- val(copy(s,1,1), colv, code);
- colvsha := shaq(star, fin, proi, colv, 1);
- writeln(colvsha);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement