From 7de121c4b4ef888a0d1990c27144a7f9dd8c5f94 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sun, 6 Nov 2016 11:13:14 +0700 Subject: Thêm đề HSG 12 huyện Vĩnh Tường, Vĩnh Phúc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 12/TP-HN-2008/R1/BL1.PAS | 26 +++++++++++++++ 12/TP-HN-2008/R1/BL2.PAS | 57 ++++++++++++++++++++++++++++++++ 12/TP-HN-2008/R1/BL3.PAS | 45 +++++++++++++++++++++++++ 12/TP-HN-2008/R1/BL4.pas | 26 +++++++++++++++ 12/TP-HN-2008/R1/CLB.IN | 4 +++ 12/TP-HN-2008/R1/CLB.OU | 0 12/TP-HN-2008/R1/R1.DOC | Bin 0 -> 79872 bytes 12/TP-HN-2008/R2/DG | Bin 0 -> 133348 bytes 12/TP-HN-2008/R2/DG.INP | 6 ++++ 12/TP-HN-2008/R2/DG.OUT | 1 + 12/TP-HN-2008/R2/DG.o | Bin 0 -> 9392 bytes 12/TP-HN-2008/R2/DG.pas | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 12/TP-HN-2008/R2/HC.pas | 23 +++++++++++++ 12/TP-HN-2008/R2/R2.doc | Bin 0 -> 64512 bytes 12/TP-HN-2008/R2/TBC.PAS | 69 +++++++++++++++++++++++++++++++++++++++ 15 files changed, 340 insertions(+) create mode 100755 12/TP-HN-2008/R1/BL1.PAS create mode 100755 12/TP-HN-2008/R1/BL2.PAS create mode 100755 12/TP-HN-2008/R1/BL3.PAS create mode 100755 12/TP-HN-2008/R1/BL4.pas create mode 100755 12/TP-HN-2008/R1/CLB.IN create mode 100755 12/TP-HN-2008/R1/CLB.OU create mode 100755 12/TP-HN-2008/R1/R1.DOC create mode 100755 12/TP-HN-2008/R2/DG create mode 100755 12/TP-HN-2008/R2/DG.INP create mode 100755 12/TP-HN-2008/R2/DG.OUT create mode 100755 12/TP-HN-2008/R2/DG.o create mode 100755 12/TP-HN-2008/R2/DG.pas create mode 100644 12/TP-HN-2008/R2/HC.pas create mode 100755 12/TP-HN-2008/R2/R2.doc create mode 100755 12/TP-HN-2008/R2/TBC.PAS (limited to '12/TP-HN-2008') diff --git a/12/TP-HN-2008/R1/BL1.PAS b/12/TP-HN-2008/R1/BL1.PAS new file mode 100755 index 0000000..6931b1b --- /dev/null +++ b/12/TP-HN-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-HN-2008/R1/BL2.PAS b/12/TP-HN-2008/R1/BL2.PAS new file mode 100755 index 0000000..e228240 --- /dev/null +++ b/12/TP-HN-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-HN-2008/R1/BL3.PAS b/12/TP-HN-2008/R1/BL3.PAS new file mode 100755 index 0000000..a49b4d6 --- /dev/null +++ b/12/TP-HN-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-HN-2008/R1/BL4.pas b/12/TP-HN-2008/R1/BL4.pas new file mode 100755 index 0000000..94dd3ba --- /dev/null +++ b/12/TP-HN-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-HN-2008/R1/CLB.IN b/12/TP-HN-2008/R1/CLB.IN new file mode 100755 index 0000000..662c775 --- /dev/null +++ b/12/TP-HN-2008/R1/CLB.IN @@ -0,0 +1,4 @@ +3 +7 9 +3 8 +10 20 diff --git a/12/TP-HN-2008/R1/CLB.OU b/12/TP-HN-2008/R1/CLB.OU new file mode 100755 index 0000000..e69de29 diff --git a/12/TP-HN-2008/R1/R1.DOC b/12/TP-HN-2008/R1/R1.DOC new file mode 100755 index 0000000..5e29da2 Binary files /dev/null and b/12/TP-HN-2008/R1/R1.DOC differ diff --git a/12/TP-HN-2008/R2/DG b/12/TP-HN-2008/R2/DG new file mode 100755 index 0000000..ad902a1 Binary files /dev/null and b/12/TP-HN-2008/R2/DG differ diff --git a/12/TP-HN-2008/R2/DG.INP b/12/TP-HN-2008/R2/DG.INP new file mode 100755 index 0000000..fb3ca57 --- /dev/null +++ b/12/TP-HN-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-HN-2008/R2/DG.OUT b/12/TP-HN-2008/R2/DG.OUT new file mode 100755 index 0000000..c227083 --- /dev/null +++ b/12/TP-HN-2008/R2/DG.OUT @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/12/TP-HN-2008/R2/DG.o b/12/TP-HN-2008/R2/DG.o new file mode 100755 index 0000000..cf2e3e1 Binary files /dev/null and b/12/TP-HN-2008/R2/DG.o differ diff --git a/12/TP-HN-2008/R2/DG.pas b/12/TP-HN-2008/R2/DG.pas new file mode 100755 index 0000000..2313685 --- /dev/null +++ b/12/TP-HN-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-HN-2008/R2/HC.pas b/12/TP-HN-2008/R2/HC.pas new file mode 100644 index 0000000..8e6b182 --- /dev/null +++ b/12/TP-HN-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-HN-2008/R2/R2.doc b/12/TP-HN-2008/R2/R2.doc new file mode 100755 index 0000000..c804058 Binary files /dev/null and b/12/TP-HN-2008/R2/R2.doc differ diff --git a/12/TP-HN-2008/R2/TBC.PAS b/12/TP-HN-2008/R2/TBC.PAS new file mode 100755 index 0000000..1a26a91 --- /dev/null +++ b/12/TP-HN-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. -- cgit 1.4.1