diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2016-10-08 09:56:43 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2016-10-08 09:56:43 +0700 |
commit | 2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0 (patch) | |
tree | 95190a32ec1c7098494849eea5a5ba6b53289585 /12 | |
parent | 207cc2ae9893b0cdecd20119b9ede37f73cd4a1e (diff) | |
download | cp-2a7bc10f6c011d19fb3b0e73068f7e1a9c30ace0.tar.gz |
Initial commit
Diffstat (limited to '12')
34 files changed, 976 insertions, 0 deletions
diff --git a/12/QG-2014/QG-2014.pdf b/12/QG-2014/QG-2014.pdf new file mode 100755 index 0000000..f9c6864 --- /dev/null +++ b/12/QG-2014/QG-2014.pdf Binary files differdiff --git a/12/TP-2008/R1/.BL4.pas.swp b/12/TP-2008/R1/.BL4.pas.swp new file mode 100755 index 0000000..013c8d2 --- /dev/null +++ b/12/TP-2008/R1/.BL4.pas.swp Binary files differdiff --git a/12/TP-2008/R1/BL1.PAS b/12/TP-2008/R1/BL1.PAS new file mode 100755 index 0000000..6931b1b --- /dev/null +++ b/12/TP-2008/R1/BL1.PAS @@ -0,0 +1,26 @@ +uses math; + +var + f : text; + m, n, i : byte; + a, b : double; +j +begin + assign(f, 'LT.IN'); + reset(f); + read(f, n, m); + close(f); + a := 1; + for i := 1 to n do + a := a * 2; + b := 1; + for i := 1 to m do + b := b * 3; + a := a + b; + for i := 1 to trunc(log10(a)) do + a := a / 10; + assign(f, 'LT.OU'); + rewrite(f); + writeln(f, trunc(a)); + close(f) +end. diff --git a/12/TP-2008/R1/BL2.PAS b/12/TP-2008/R1/BL2.PAS new file mode 100755 index 0000000..e228240 --- /dev/null +++ b/12/TP-2008/R1/BL2.PAS @@ -0,0 +1,57 @@ +type + rect = record + a : longint; + b : longint + end; + arec = array of rect; + +var + f : text; + c, d, e : rect; + +function join(g, h : rect) : arec; + var n : byte = 0; + procedure j01n(p, q : longint); + begin + inc(n); + setlength(join, n); + join[n - 1].a := p; + join[n - 1].b := q + end; + begin + if g.a = h.a then j01n(g.a, g.b + h.b); + if g.a = h.b then j01n(g.a, g.b + h.a); + if g.b = h.a then j01n(g.b, g.a + h.b); + if g.b = h.b then j01n(g.b, g.a + h.a); + end; + +procedure out(m : longint); + begin + assign(f, 'GH.OU'); + rewrite(f); + writeln(f, m); + close(f); + halt + end; + +procedure libl2(x, y, z : rect); + var i, j : rect; + begin + for i in join(x, y) do + for j in join(z, i) do + if (j.a = j.b) and (j.a <> 0) then + out(j.a) + end; + +begin + assign(f, 'GH.IN'); + reset(f); + readln(f, c.a, c.b); + readln(f, d.a, d.b); + readln(f, e.a, e.b); + close(f); + libl2(c, d, e); + libl2(d, e, c); + libl2(e, c, d); + out(0) +end. diff --git a/12/TP-2008/R1/BL3.PAS b/12/TP-2008/R1/BL3.PAS new file mode 100755 index 0000000..a49b4d6 --- /dev/null +++ b/12/TP-2008/R1/BL3.PAS @@ -0,0 +1,45 @@ +type ar = array[0..3] of longint; + +var + f : text; + m, n, i, j : shortint; + a : array[1..101, -1..102] of longint; + tmp, max : longint; + +function next(x, y : shortint) : ar; + begin + next[0] := a[x + 1, y - 2]; + next[1] := a[x + 1, y + 2]; + next[2] := a[x + 2, y - 1]; + next[3] := a[x + 2, y + 1] + end; + +begin + for i := 1 to 101 do + for j := -1 to 102 do + a[i, j] := 0; + assign(f, 'QM.IN'); + reset(f); + readln(f, m, n); + for i := 1 to m do + for j := 1 to n do + read(f, a[i, j]); + close(f); + for i := m - 1 downto 1 do + for j := 1 to n do + begin + max := 0; + for tmp in next(i, j) do + if tmp > max then + max := tmp; + a[i, j] := a[i, j] + max; + end; + assign(f, 'QM.OU'); + rewrite(f); + max := 0; + for i := 1 to n do + if a[1, i] > max then + max := a[1, i]; + writeln(f, max); + close(f); +end. diff --git a/12/TP-2008/R1/BL4.pas b/12/TP-2008/R1/BL4.pas new file mode 100755 index 0000000..94dd3ba --- /dev/null +++ b/12/TP-2008/R1/BL4.pas @@ -0,0 +1,26 @@ +var + f : text; + n : word; + a, b : array of longword; + tmp0, tmp1 : longword; + +procedure ins(var l : array of longword; x : longword); + begin + setlength(l, length(l) + 1); + l[length(l) - 1] := x + end; + +begin + setlength(a, 0); + setlength(b, 0); + assign(f, 'CLB.IN'); + reset(f); + readln(f, n); + for i := 1 to n do + begin + readln(f, tmp0, tmp1); + ins(a, tmp0); + ins(b, tmp1) + end; + close(f); + diff --git a/12/TP-2008/R1/CLB.IN b/12/TP-2008/R1/CLB.IN new file mode 100755 index 0000000..662c775 --- /dev/null +++ b/12/TP-2008/R1/CLB.IN @@ -0,0 +1,4 @@ +3 +7 9 +3 8 +10 20 diff --git a/12/TP-2008/R1/CLB.OU b/12/TP-2008/R1/CLB.OU new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/12/TP-2008/R1/CLB.OU diff --git a/12/TP-2008/R1/R1.DOC b/12/TP-2008/R1/R1.DOC new file mode 100755 index 0000000..5e29da2 --- /dev/null +++ b/12/TP-2008/R1/R1.DOC Binary files differdiff --git a/12/TP-2008/R2/.DG.pas.swp b/12/TP-2008/R2/.DG.pas.swp new file mode 100644 index 0000000..7227844 --- /dev/null +++ b/12/TP-2008/R2/.DG.pas.swp Binary files differdiff --git a/12/TP-2008/R2/DG b/12/TP-2008/R2/DG new file mode 100755 index 0000000..ad902a1 --- /dev/null +++ b/12/TP-2008/R2/DG Binary files differdiff --git a/12/TP-2008/R2/DG.INP b/12/TP-2008/R2/DG.INP new file mode 100755 index 0000000..fb3ca57 --- /dev/null +++ b/12/TP-2008/R2/DG.INP @@ -0,0 +1,6 @@ +4 +0 1 +1 0 +0 -1 +-1 0 +-2 0 0 0 diff --git a/12/TP-2008/R2/DG.OUT b/12/TP-2008/R2/DG.OUT new file mode 100755 index 0000000..c227083 --- /dev/null +++ b/12/TP-2008/R2/DG.OUT @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/12/TP-2008/R2/DG.o b/12/TP-2008/R2/DG.o new file mode 100755 index 0000000..cf2e3e1 --- /dev/null +++ b/12/TP-2008/R2/DG.o Binary files differdiff --git a/12/TP-2008/R2/DG.pas b/12/TP-2008/R2/DG.pas new file mode 100755 index 0000000..2313685 --- /dev/null +++ b/12/TP-2008/R2/DG.pas @@ -0,0 +1,83 @@ +type bigboo = [-1..1]; + +var + f : text; + n, i, j : byte; + inp : array[0..100] of PointType; + P, Q : PointType; + P_out, Q_out : boolean; + s : int64 = 0; + +function stri2(A, B, C : PointType) : int64; + begin + stri2 := (C.y - A.y) * (A.x - B.x) - (C.x - A.x) * (A.y - B.y) + end; + +function outpoly(M : PointType) : int64; + begin + outpoly := s; + for i := 0 to n - 1 do + begin + outpoly := outpoly - abs(stri2(M, inp[i], inp[i + 1])) + end + end; + +function sign(x : smallint) : bigboo; + begin + case true of + x > 0 : exit(1); + x = 0 : exit(0); + x < 0 : exit(-1) + end + end; + +function intersect(A, B : PointType) : bigboo; + var b00, b01 : bigboo; + begin + b00 := sign(stri2(P, Q, A)); + b01 := sign(stri2(P, Q, A)); + if b00 = b01 then + if b00 = 0 then exit(0) + else exit(-1); + b00 := sign(stri2(A, B, P)); + b01 := sign(stri2(A, B, Q)); + if b00 = b01 then + if b00 = 0 then exit(0) + else exit(-1); + exit(1) + end; + +function lensqr(A, B : PointType) : int64; + begin + exit() + end; + +procedure out(M, N : PointType); + begin + assign(f, 'DG.OUT'); + rewrite(f); + write(f, trunc(sqrt(sqr(A.x - B.x) + sqr(A.y - B.y)) * 100)); + close(f); + halt + end; + +begin + assign(f, 'DG.INP'); + reset(f); + readln(f, n); + for i := 0 to n - 1 do + readln(f, inp[i].x, inp[i].y); + inp[n] := inp[0]; + readln(f, P.x, P.y, Q.x, Q.y); + close(f); + for i := 1 to n - 2 do + s := s + abs(stri2(inp[0], inp[i], inp[i + 1])); + if outpoly(P) = 0 then + P_out := false; + if outpoly(Q) = 0 then + Q_out := false; + if P_out and Q_out then + for i := 0 to n - 1 do + + out(P, Q) +end. diff --git a/12/TP-2008/R2/HC.pas b/12/TP-2008/R2/HC.pas new file mode 100644 index 0000000..8e6b182 --- /dev/null +++ b/12/TP-2008/R2/HC.pas @@ -0,0 +1,23 @@ +var + f : text; + m, n, i, j : byte; + a : array[1..200, 0..200] of smallint; + +function out + +begin + assign(f, 'HC.INP'); + reset(f); + readln(f, m, n); + for i := 1 to m do + begin + a[i, 0] := 0; + for j := 1 to n do + read(f, a[i, j]) + end; + close(f); + assign(f, 'HC.OUT'); + rewrite(f); + writeln(f, out(a)); + close(f) +end; diff --git a/12/TP-2008/R2/R2.doc b/12/TP-2008/R2/R2.doc new file mode 100755 index 0000000..c804058 --- /dev/null +++ b/12/TP-2008/R2/R2.doc Binary files differdiff --git a/12/TP-2008/R2/TBC.PAS b/12/TP-2008/R2/TBC.PAS new file mode 100755 index 0000000..1a26a91 --- /dev/null +++ b/12/TP-2008/R2/TBC.PAS @@ -0,0 +1,69 @@ +var + f : text; + i, l, m, n : integer; + a : array[1..1000] of longint; + +procedure qsort(l, h : integer); + var + i, j : integer; + x, tmp : longint; + begin + i := l; + j := h; + x := a[(i + j) div 2]; + repeat + while a[i] < x do inc(i); + while x < a[j] do dec(j); + if i <= j then + begin + tmp := a[i]; + a[i] := a[j]; + a[j] := tmp; + inc(i); + dec(j) + end + until i > j; + if l < j then qsort(l, j); + if i < h then qsort(i, h) + end; + +function biin(n0 : integer) : boolean; + var l, h, m : integer; + begin + l := 1; + h := n; + repeat + m := (l + h) div 2; + if a[m] = n0 then exit(true); + if a[m] < n0 then l := m + 1 + else h := m - 1 + until l > h; + biin := false + end; + +function libtbc(n0 : integer) : boolean; + var i, j : integer; + begin + for i := 1 to n0 - 1 do + for j := n0 + 1 to n do + if biin(a[n0] * 3 - a[i] - a[j]) then + exit(true); + libtbc := false + end; + +begin + assign(f, 'TBC.INP'); + reset(f); + readln(f, n); + for i := 1 to n do readln(f, a[i]); + close(f); + qsort(1, n); + m := 0; + for l := 2 to n - 1 do + if libtbc(l) then + inc(m); + assign(f, 'TBC.OUT'); + rewrite(f); + writeln(f, m); + close(f) +end. diff --git a/12/TP-2009/R1/BTN.PAS b/12/TP-2009/R1/BTN.PAS new file mode 100755 index 0000000..dbb022d --- /dev/null +++ b/12/TP-2009/R1/BTN.PAS @@ -0,0 +1,87 @@ +type sni = record + s : ansistring; + n : integer +end; + +var + f : text; + s : ansistring; + op, cl : integer; + c : char; + +function cal(s : ansistring) : integer; + var + c : char; + tmp : integer = 0; + begin + cal := 0; + for c in s do + if c = '(' then + begin + inc(tmp); + if tmp > cal then + cal := tmp + end + else + begin + dec(tmp); + if tmp < 0 then exit(0) + end; + if tmp <> 0 then + exit(0) + end; + +function rplc( + s : ansistring; + c : char; + idx : integer +) : ansistring; + begin + exit(copy(s, 1, idx - 1) + c + copy(s, idx + 1, length(s) - idx + 1)) + end; + +function libtn( + s : ansistring; + op, cl, idx : integer +) : sni; + var + i : integer; + v0, v1 : sni; + begin + if (op = 0) and (cl = 0) then + begin + libtn.s := s; + libtn.n := cal(s); + exit + end; + i := idx; + while s[i] <> '?' do + inc(i); + if op = 0 then + exit(libtn(rplc(s, ')', i), 0, cl - 1, i + 1)); + if cl = 0 then + exit(libtn(rplc(s, '(', i), op - 1, 0, i + 1)); + v0 := libtn(rplc(s, '(', i), op - 1, cl, i + 1); + v1 := libtn(rplc(s, ')', i), op, cl - 1, i + 1); + if v0.n > v1.n then + exit(v0) + else exit(v1) + end; + +begin + assign(f, 'BTN.INP'); + reset(f); + read(f, s); + close(f); + op := length(s) div 2; + cl := length(s) div 2; + for c in s do + if c = '(' then + dec(op) + else if c = ')' then + dec(cl); + assign(f, 'BTN.OUT'); + rewrite(f); + writeln(f, libtn(s, op, cl, 1).s); + close(f) +end. diff --git a/12/TP-2009/R1/HEXA.PAS b/12/TP-2009/R1/HEXA.PAS new file mode 100755 index 0000000..a2fd6ca --- /dev/null +++ b/12/TP-2009/R1/HEXA.PAS @@ -0,0 +1,75 @@ +var + f : text; + n, n0, m, i, j, tmp : longint; + s : string; + +function dec2hex(deca : longint) : string; + var + a : array[0..7] of byte; + i, j : byte; + begin + dec2hex := ''; + i := 0; + while deca > 0 do + begin + a[i] := deca mod 16; + deca := deca div 16; + inc(i) + end; + dec(i); + for j := i downto 0 do + case a[j] of + 0 : dec2hex := dec2hex + '0'; + 1 : dec2hex := dec2hex + '1'; + 2 : dec2hex := dec2hex + '2'; + 3 : dec2hex := dec2hex + '3'; + 4 : dec2hex := dec2hex + '4'; + 5 : dec2hex := dec2hex + '5'; + 6 : dec2hex := dec2hex + '6'; + 7 : dec2hex := dec2hex + '7'; + 8 : dec2hex := dec2hex + '8'; + 9 : dec2hex := dec2hex + '9'; + 10 : dec2hex := dec2hex + 'A'; + 11 : dec2hex := dec2hex + 'B'; + 12 : dec2hex := dec2hex + 'C'; + 13 : dec2hex := dec2hex + 'D'; + 14 : dec2hex := dec2hex + 'E'; + 15 : dec2hex := dec2hex + 'F' + end + end; + +begin + assign(f, 'HEXA.INP'); + reset(f); + read(f, n); + close(f); + m := n; + i := 0; + while m > 0 do + begin + inc(i); + tmp := 1; + for j := 1 to i - 1 do tmp := tmp * 16; + m := m + i * (tmp - tmp * 16) + end; + m := i; + for i := 1 to m - 1 do + begin + tmp := 1; + for j := 1 to i - 1 do tmp := tmp * 16; + n := n + i * (tmp - tmp * 16) + end; + n0 := (n + m - 1) div m; + for i := 1 to m - 1 do + begin + tmp := 1; + for j := 1 to i - 1 do tmp := tmp * 16; + n0 := n0 + tmp * 16 - tmp + end; + s := dec2hex(n0); + if n mod m > 0 then m := n mod m; + assign(f, 'HEXA.OUT'); + rewrite(f); + writeln(f, s[m]); + close(f) +end. diff --git a/12/TP-2009/R1/PS.PAS b/12/TP-2009/R1/PS.PAS new file mode 100755 index 0000000..6cf2d09 --- /dev/null +++ b/12/TP-2009/R1/PS.PAS @@ -0,0 +1,80 @@ +var + f : text; + m, n : byte; + k, i, j, l, gcd0 : integer; + a, b : array[1..30] of integer; + c : array[0..1, 1..900] of integer; + +function gcd(d, e : integer) : integer; + var tmp : integer; + begin + while d > 0 do + begin + tmp := d; + d := e mod d; + e := tmp + end; + gcd := e + end; + +procedure qsort(b, e: integer); + var i, j, x, tmp: integer; + begin + i := b; + j := e; + x := (b + e) div 2; + repeat + while c[0, i] * c[1, x] < c[0, x] * c[1, i] do inc(i); + while c[0, x] * c[1, j] < c[0, j] * c[1, x] do dec(j); + if i <= j then + begin + tmp := c[0, i]; + c[0, i] := c[0, j]; + c[0, j] := tmp; + tmp := c[1, i]; + c[1, i] := c[1, j]; + c[1, j] := tmp; + inc(i); + dec(j) + end + until i > j; + if b < j then qsort(b, j); + if i < e then qsort(i, e) + end; + +begin + assign(f, 'PS.INP'); + reset(f); + read(f, m, n, k); + for i := 1 to m do read(f, a[i]); + for i := 1 to n do read(f, b[i]); + close(f); + l := 0; + for i := 1 to m do + for j := 1 to n do + begin + inc(l); + gcd0 := gcd(a[i], b[j]); + c[0, l] := a[i] div gcd0; + c[1, l] := b[j] div gcd0 + end; + qsort(1, l); + i := 1; + while i < l do + begin + inc(i); + if c[0, i] * c[1, i - 1] = c[0, i - 1] * c[1, i] then + begin + dec(l); + for j := i to l do + begin + c[0, j] := c[0, j + 1]; + c[1, j] := c[1, j + 1] + end + end + end; + assign(f, 'PS.OUT'); + rewrite(f); + writeln(f, c[0, k], ' ', c[1, k]); + close(f) +end. diff --git a/12/TP-2009/R1/R1.pdf b/12/TP-2009/R1/R1.pdf new file mode 100755 index 0000000..b0834b3 --- /dev/null +++ b/12/TP-2009/R1/R1.pdf Binary files differdiff --git a/12/TP-2009/R2/BAI1.PAS b/12/TP-2009/R2/BAI1.PAS new file mode 100755 index 0000000..b28ae0b --- /dev/null +++ b/12/TP-2009/R2/BAI1.PAS @@ -0,0 +1,90 @@ +uses math; + +var + f : text; + n : longint; + lena, i : integer; + a : array[1..512] of longint; + +procedure insort(x : longint); + var i, j : integer; + begin + inc(lena); + a[lena] := x - 1; + for i := 1 to lena do + if a[i] < x then begin + for j := lena downto i + 1 do + a[j] := a[j - 1]; + a[i] := x; + exit + end + end; + +function notin(x : longint) : boolean; + var l, h, m : integer; + begin + l := 1; + h := lena; + repeat + m := (l + h) div 2; + if a[m] = x then exit(false); + if a[m] < x then h := m - 1 + else l := m + 1 + until l > h; + notin := true + end; + +procedure mklist(n0 : longint); + var + i, j : byte; + n10, m0 : longint; + begin + if n0 <> 0 then begin + insort(n0); + for i := 0 to trunc(log10(n0)) do + begin + n10 := 1; + for j := 1 to i do n10 := n10 * 10; + m0 := n0 div (n10 * 10) + n0 mod n10; + if notin(m0) then mklist(m0) + end + end + end; + +function prime(m : longint) : boolean; + var p, q : integer; + begin + if m < 2 then exit(false); + if m = 2 then exit(true); + if m = 3 then exit(true); + if m mod 2 = 0 then exit(false); + if m mod 3 = 0 then exit(false); + p := 5; + q := 2; + while p * p <= m do + begin + if m mod p = 0 then exit(false); + p := p + q; + q := 6 - q + end; + prime := true + end; + +begin + assign(f, 'BAI1.INP'); + reset(f); + read(f, n); + close(f); + lena := 0; + mklist(n); + assign(f, 'BAI1.OUT'); + rewrite(f); + for i := 1 to lena do + if prime(a[i]) then begin + writeln(f, a[i]); + close(f); + exit + end; + writeln(f, -1); + close(f) +end. diff --git a/12/TP-2009/R2/BAI3.PAS b/12/TP-2009/R2/BAI3.PAS new file mode 100755 index 0000000..30eecdf --- /dev/null +++ b/12/TP-2009/R2/BAI3.PAS @@ -0,0 +1,87 @@ +type + ar = array of ansistring; + +var + f : text; + s0 : ansistring; + a0 : ar; + +function incre(s1, s2 : ansistring) : boolean; + var + i : smallint; + begin + if length(s1) < length(s2) then exit(true); + if length(s1) > length(s2) then exit(false); + for i := 1 to length(s1) do + begin + if ord(s1[i]) < ord(s2[i]) then exit(true); + if ord(s1[i]) > ord(s2[i]) then exit(false) + end; + exit(false) + end; + +function cal(a : ar) : smallint; + var + len, i, tmp : smallint; + begin + cal := 0; + i := 0; + len := length(a); + while (cal + i < len) and (i + 1 < len) do + begin + inc(i); + if incre(a[0], a[i]) then + begin + tmp := cal(copy(a, i, len - i)) + 1; + if tmp > cal then + cal := tmp + end + end + end; + +function putin( + aray : ar; + strng : ansistring; + len : smallint +) : ar; + begin + setlength(aray, length(aray) + 1); + aray[length(aray) - 1] := copy(strng, 1, len); + exit(aray) + end; + +function libai3( + s : ansistring; + a : ar; + n : smallint +) : smallint; + var + len, i, tmp : smallint; + begin + if s = '' then + exit(cal(a)); + libai3 := 0; + len := length(s); + i := 0; + while (i < n) and (i + libai3 < len) do + begin + inc(i); + tmp := libai3(copy(s, i + 1, len - i), putin(a, s, i), n + 1); + if tmp > libai3 then + libai3 := tmp + end + end; + +begin + assign(f, 'BAI3.INP'); + reset(f); + readln(f); + read(f, s0); + close(f); + setlength(a0, 1); + a0[0] := ''; + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(f, libai3(s0, a0, 1)); + close(f) +end. diff --git a/12/TP-2009/R2/R2.pdf b/12/TP-2009/R2/R2.pdf new file mode 100755 index 0000000..7af542a --- /dev/null +++ b/12/TP-2009/R2/R2.pdf Binary files differdiff --git a/12/TP-2010/BAI1.PAS b/12/TP-2010/BAI1.PAS new file mode 100755 index 0000000..029201d --- /dev/null +++ b/12/TP-2010/BAI1.PAS @@ -0,0 +1,30 @@ +var + f : text; + i : 1..30; + a : array[0..30] of qword; + +function gcd(a, b : qword) : qword; + var tmp : qword; + begin + while b > 0 do + begin + tmp := b; + b := a mod b; + a := tmp + end; + gcd := a + end; + +begin + assign(f, 'bai1.inp'); + reset(f); + readln(f, a[0]); + for i := 1 to a[0] do read(f, a[i]); + close(f); + for i := a[0] - 1 downto 1 do + a[i] := a[i] * a[i + 1] div gcd(a[i], a[i + 1]); + assign(f, 'bai1.out'); + rewrite(f); + writeln(f, a[1]); + close(f) +end. diff --git a/12/TP-2010/BAI2.PAS b/12/TP-2010/BAI2.PAS new file mode 100755 index 0000000..d6639df --- /dev/null +++ b/12/TP-2010/BAI2.PAS @@ -0,0 +1,40 @@ +var + f : text; + s : string; + len, i, j : byte; + count : integer = 0; + +function libai2(s0 : string) : boolean; + var + bo, boo, b0 : boolean; + c : char; + begin + b0 := false; + bo := false; + boo := false; + for c in s0 do + begin + case c of + '0' .. '9' : b0 := true; + 'a' .. 'z' : bo := true; + 'A' .. 'Z' : boo := true + end; + if b0 and bo and boo then exit(true) + end; + exit(false); + end; + +begin + assign(f, 'BAI2.INP'); + reset(f); + read(f, s); + close(f); + len := length(s); + for i := 1 to len - 5 do + for j := 6 to len - i + 1 do + if libai2(copy(s, i, j)) then inc(count); + assign(f, 'BAI2.OUT'); + rewrite(f); + writeln(f, count); + close(f) +end. diff --git a/12/TP-2010/BAI3 b/12/TP-2010/BAI3 new file mode 100755 index 0000000..7b83e7b --- /dev/null +++ b/12/TP-2010/BAI3 Binary files differdiff --git a/12/TP-2010/BAI3.INP b/12/TP-2010/BAI3.INP new file mode 100755 index 0000000..3609812 --- /dev/null +++ b/12/TP-2010/BAI3.INP @@ -0,0 +1 @@ +5 5 0 diff --git a/12/TP-2010/BAI3.OUT b/12/TP-2010/BAI3.OUT new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/12/TP-2010/BAI3.OUT diff --git a/12/TP-2010/BAI3.o b/12/TP-2010/BAI3.o new file mode 100755 index 0000000..7706cd6 --- /dev/null +++ b/12/TP-2010/BAI3.o Binary files differdiff --git a/12/TP-2010/BAI3.pas b/12/TP-2010/BAI3.pas new file mode 100755 index 0000000..aedf9a0 --- /dev/null +++ b/12/TP-2010/BAI3.pas @@ -0,0 +1,73 @@ +type + board = array[0..31, 0..31] of boolean; + +var + f : text; + a : board; + i, j, k, l, m, n : byte; + +function king( + e : board; + x, y : byte +) : board; + var z, t : byte; + begin + for z := x - 1 to x + 1 do + for t := y - 1 to y + 1 do + e[z, t] := true; + exit(e) + end; + +function full(c : board) : boolean; + var d : boolean; + begin + for d in c do + if not(d) then + exit(false); + exit(true) + end; + +function libai3( + b : board; + x0, y0 : byte +) : byte; + type tmp = record + n, x, y : byte + end; + var + max : tmp; + t, x, y : byte; + begin + if full(b) then exit(0); + max.n := 0; + for x := x0 to m do + for y := y0 to n do + if not(b[x, y]) then + begin + t := libai3(king(b, x, y), x + 1, y + 1) + 1; + writeln(t); + if t > max.n then + begin + max.x := x; + max.y := y; + max.n := t + end + end; + exit(max.n) + end; + +begin + assign(f, 'BAI3.INP'); + reset(f); + readln(f, m, n, k); + for l := 1 to k do + begin + readln(f, i, j); + a := king(a, i, j) + end; + close(f); + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(libai3(a, 1, 1)); + close(f) +end. diff --git a/12/TP-2010/TP-2010.png b/12/TP-2010/TP-2010.png new file mode 100755 index 0000000..7eacc66 --- /dev/null +++ b/12/TP-2010/TP-2010.png Binary files differdiff --git a/12/TP-2010/_BAI3.pas b/12/TP-2010/_BAI3.pas new file mode 100644 index 0000000..09ec0ca --- /dev/null +++ b/12/TP-2010/_BAI3.pas @@ -0,0 +1,73 @@ +type + board = array[0..1023] of boolean; + +var + f : text; + a : board; + i, j, k, l, m, n : byte; + +function king( + e : board; + x, y : byte +) : board; + var z, t : byte; + begin + for z := x - 1 to x + 1 do + for t := y - 1 to y + 1 do + e[z, t] := true; + exit(e) + end; + +function full(c : board) : boolean; + var d : boolean; + begin + for d in c do + if not(d) then + exit(false); + exit(true) + end; + +function libai3( + b : board; + x0, y0 : byte +) : byte; + type tmp = record + n, x, y : byte + end; + var + max : tmp; + t, x, y : byte; + begin + if full(b) then exit(0); + max.n := 0; + for x := x0 to m do + for y := y0 to n do + if not(b[x, y]) then + begin + t := libai3(king(b, x, y), x + 1, y + 1) + 1; + writeln(t); + if t > max.n then + begin + max.x := x; + max.y := y; + max.n := t + end + end; + exit(max.n) + end; + +begin + assign(f, 'BAI3.INP'); + reset(f); + readln(f, m, n, k); + for l := 1 to k do + begin + readln(f, i, j); + a := king(a, i, j) + end; + close(f); + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(libai3(a, 1, 1)); + close(f) +end. |