about summary refs log tree commit diff
path: root/2ndary/12/TP-HN-2010
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-2010
parentb2d80610db6beda38573890ed169815e495bc663 (diff)
downloadcp-2f674dc80f0382f1c3178f435714960734dc9d3c.tar.gz
Reorganize stuff from secondary school
Diffstat (limited to '2ndary/12/TP-HN-2010')
-rw-r--r--2ndary/12/TP-HN-2010/BAI1.PAS30
-rw-r--r--2ndary/12/TP-HN-2010/BAI2.PAS40
-rw-r--r--2ndary/12/TP-HN-2010/BAI3bin0 -> 132580 bytes
-rw-r--r--2ndary/12/TP-HN-2010/BAI3.INP1
-rw-r--r--2ndary/12/TP-HN-2010/BAI3.OUT0
-rw-r--r--2ndary/12/TP-HN-2010/BAI3.obin0 -> 4344 bytes
-rw-r--r--2ndary/12/TP-HN-2010/BAI3.pas73
-rw-r--r--2ndary/12/TP-HN-2010/README.md1
-rw-r--r--2ndary/12/TP-HN-2010/TP-2010.pngbin0 -> 1251665 bytes
-rw-r--r--2ndary/12/TP-HN-2010/_BAI3.pas73
10 files changed, 218 insertions, 0 deletions
diff --git a/2ndary/12/TP-HN-2010/BAI1.PAS b/2ndary/12/TP-HN-2010/BAI1.PAS
new file mode 100644
index 0000000..029201d
--- /dev/null
+++ b/2ndary/12/TP-HN-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/2ndary/12/TP-HN-2010/BAI2.PAS b/2ndary/12/TP-HN-2010/BAI2.PAS
new file mode 100644
index 0000000..d6639df
--- /dev/null
+++ b/2ndary/12/TP-HN-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/2ndary/12/TP-HN-2010/BAI3 b/2ndary/12/TP-HN-2010/BAI3
new file mode 100644
index 0000000..7b83e7b
--- /dev/null
+++ b/2ndary/12/TP-HN-2010/BAI3
Binary files differdiff --git a/2ndary/12/TP-HN-2010/BAI3.INP b/2ndary/12/TP-HN-2010/BAI3.INP
new file mode 100644
index 0000000..3609812
--- /dev/null
+++ b/2ndary/12/TP-HN-2010/BAI3.INP
@@ -0,0 +1 @@
+5 5 0
diff --git a/2ndary/12/TP-HN-2010/BAI3.OUT b/2ndary/12/TP-HN-2010/BAI3.OUT
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/2ndary/12/TP-HN-2010/BAI3.OUT
diff --git a/2ndary/12/TP-HN-2010/BAI3.o b/2ndary/12/TP-HN-2010/BAI3.o
new file mode 100644
index 0000000..7706cd6
--- /dev/null
+++ b/2ndary/12/TP-HN-2010/BAI3.o
Binary files differdiff --git a/2ndary/12/TP-HN-2010/BAI3.pas b/2ndary/12/TP-HN-2010/BAI3.pas
new file mode 100644
index 0000000..aedf9a0
--- /dev/null
+++ b/2ndary/12/TP-HN-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/2ndary/12/TP-HN-2010/README.md b/2ndary/12/TP-HN-2010/README.md
new file mode 100644
index 0000000..625312d
--- /dev/null
+++ b/2ndary/12/TP-HN-2010/README.md
@@ -0,0 +1 @@
+![](TP-2010.png)
diff --git a/2ndary/12/TP-HN-2010/TP-2010.png b/2ndary/12/TP-HN-2010/TP-2010.png
new file mode 100644
index 0000000..7eacc66
--- /dev/null
+++ b/2ndary/12/TP-HN-2010/TP-2010.png
Binary files differdiff --git a/2ndary/12/TP-HN-2010/_BAI3.pas b/2ndary/12/TP-HN-2010/_BAI3.pas
new file mode 100644
index 0000000..09ec0ca
--- /dev/null
+++ b/2ndary/12/TP-HN-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.