about summary refs log tree commit diff
path: root/12
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2016-11-21 23:10:19 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2016-11-22 07:52:31 +0700
commit70f37066d2d368a2810a2be209ae0bd8b391293b (patch)
treee8937b365e76748ede468fd0e30c286ba3bce09e /12
parent48dffc6138fb90c2df90207b7b3d3291f8498001 (diff)
downloadcp-70f37066d2d368a2810a2be209ae0bd8b391293b.tar.gz
12/TP-ThanhHoá-2009: Add bai3.pas
Diffstat (limited to '12')
-rw-r--r--12/TP-ThanhHoá-2009/bai3.pas44
1 files changed, 44 insertions, 0 deletions
diff --git a/12/TP-ThanhHoá-2009/bai3.pas b/12/TP-ThanhHoá-2009/bai3.pas
new file mode 100644
index 0000000..a98141e
--- /dev/null
+++ b/12/TP-ThanhHoá-2009/bai3.pas
@@ -0,0 +1,44 @@
+var
+  f: text;
+  s: string;
+  min: byte = 255;
+
+
+procedure palen(
+  s: string;
+  tmp: smallint
+);
+
+  begin
+    if tmp + length(s) >= min then
+      exit;
+
+    if length(s) < 2 then
+      begin
+        min := tmp + length(s);
+        exit
+      end;
+
+    if s[1] = s[length(s)] then
+      palen(copy(s, 2, length(s) - 2), tmp + 2)
+    else
+      begin
+        palen(copy(s, 2, length(s) - 1), tmp + 2);
+        palen(copy(s, 1, length(s) - 1), tmp + 2)
+      end
+  end;
+
+
+begin
+  assign(f, 'BAI3.INP');
+  reset(f);
+  read(f, s);
+  close(f);
+
+  palen(s, -length(s));
+
+  assign(f, 'BAI3.OUT');
+  rewrite(f);
+  writeln(f, min);
+  close(f)
+end.