about summary refs log tree commit diff
path: root/2ndary/12/TP-HN-2008/R1
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2020-06-06 21:33:13 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2020-06-06 21:33:13 +0700
commit2f674dc80f0382f1c3178f435714960734dc9d3c (patch)
tree2abba7e4ec72bd16f58f7375126144d3fd9f4bca /2ndary/12/TP-HN-2008/R1
parentb2d80610db6beda38573890ed169815e495bc663 (diff)
downloadcp-2f674dc80f0382f1c3178f435714960734dc9d3c.tar.gz
Reorganize stuff from secondary school
Diffstat (limited to '2ndary/12/TP-HN-2008/R1')
-rw-r--r--2ndary/12/TP-HN-2008/R1/BL1.PAS26
-rw-r--r--2ndary/12/TP-HN-2008/R1/BL2.PAS57
-rw-r--r--2ndary/12/TP-HN-2008/R1/BL3.PAS45
-rw-r--r--2ndary/12/TP-HN-2008/R1/BL4.pas62
-rw-r--r--2ndary/12/TP-HN-2008/R1/CLB.IN4
-rw-r--r--2ndary/12/TP-HN-2008/R1/CLB.OU0
-rw-r--r--2ndary/12/TP-HN-2008/R1/R1.DOCbin0 -> 79872 bytes
7 files changed, 194 insertions, 0 deletions
diff --git a/2ndary/12/TP-HN-2008/R1/BL1.PAS b/2ndary/12/TP-HN-2008/R1/BL1.PAS
new file mode 100644
index 0000000..6931b1b
--- /dev/null
+++ b/2ndary/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/2ndary/12/TP-HN-2008/R1/BL2.PAS b/2ndary/12/TP-HN-2008/R1/BL2.PAS
new file mode 100644
index 0000000..e228240
--- /dev/null
+++ b/2ndary/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/2ndary/12/TP-HN-2008/R1/BL3.PAS b/2ndary/12/TP-HN-2008/R1/BL3.PAS
new file mode 100644
index 0000000..a49b4d6
--- /dev/null
+++ b/2ndary/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/2ndary/12/TP-HN-2008/R1/BL4.pas b/2ndary/12/TP-HN-2008/R1/BL4.pas
new file mode 100644
index 0000000..c552b0d
--- /dev/null
+++ b/2ndary/12/TP-HN-2008/R1/BL4.pas
@@ -0,0 +1,62 @@
+var
+  f: text;
+  n, i: int16;
+  a, b: array of int32;
+
+
+procedure swp(var x, y: int32);
+  var
+    tmp: int32;
+
+  begin
+    tmp := x;
+    x := y;
+    y := tmp
+  end;
+
+
+procedure qsort(l, h: int16);
+  var
+    i, j: int16;
+    tmp: int32;
+
+  begin
+    i := l;
+    j := h;
+    tmp := a[(l + h) div 2];
+
+    repeat
+      while a[i] < tmp do
+        inc(i);
+      while a[j] > tmp do
+        dec(j);
+
+      if i <= j then
+        begin
+          swp(a[i], a[j]);
+          swp(b[i], b[j]);
+          inc(i);
+          dec(j)
+        end;
+    until i > j;
+
+    if l < j then
+      qsort(l, j);
+    if i < h then
+      qsort(i, h)
+  end;
+
+
+begin
+  assign(f, 'CLB.IN');
+  reset(f);
+  readln(f, n);
+  setlength(a, n);
+  setlength(b, n);
+  for i := 0 to n - 1 do
+    readln(f, a[i], b[i]);
+  close(f);
+  qsort(0, n - 1);
+  for i := 0 to n - 1 do
+    writeln(a[i], ' ', b[i])
+end.
diff --git a/2ndary/12/TP-HN-2008/R1/CLB.IN b/2ndary/12/TP-HN-2008/R1/CLB.IN
new file mode 100644
index 0000000..662c775
--- /dev/null
+++ b/2ndary/12/TP-HN-2008/R1/CLB.IN
@@ -0,0 +1,4 @@
+3
+7 9
+3 8
+10 20
diff --git a/2ndary/12/TP-HN-2008/R1/CLB.OU b/2ndary/12/TP-HN-2008/R1/CLB.OU
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/2ndary/12/TP-HN-2008/R1/CLB.OU
diff --git a/2ndary/12/TP-HN-2008/R1/R1.DOC b/2ndary/12/TP-HN-2008/R1/R1.DOC
new file mode 100644
index 0000000..5e29da2
--- /dev/null
+++ b/2ndary/12/TP-HN-2008/R1/R1.DOC
Binary files differ