about summary refs log tree commit diff
path: root/12/TP-ThanhHoá-2009/bai1.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2016-11-19 19:00:47 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2016-11-19 20:46:04 +0700
commitf97ad3e9e225a288e7a8a53c2ef0acb45a47dbde (patch)
tree4d2d7ff6fd480396ed862069e7edc26fa7b66ccd /12/TP-ThanhHoá-2009/bai1.pas
parent10de10a507238f3be43dee304e057679b5bb2736 (diff)
downloadcp-f97ad3e9e225a288e7a8a53c2ef0acb45a47dbde.tar.gz
Thêm đề 12 Thanh Hoá 2008-2009
Diffstat (limited to '12/TP-ThanhHoá-2009/bai1.pas')
-rw-r--r--12/TP-ThanhHoá-2009/bai1.pas39
1 files changed, 39 insertions, 0 deletions
diff --git a/12/TP-ThanhHoá-2009/bai1.pas b/12/TP-ThanhHoá-2009/bai1.pas
new file mode 100644
index 0000000..511d074
--- /dev/null
+++ b/12/TP-ThanhHoá-2009/bai1.pas
@@ -0,0 +1,39 @@
+var
+  prime: array[1..4999] of boolean;
+  n, i, k, a, j: word;
+  f: text;
+
+begin
+  fillchar(prime, sizeof(prime), true);
+  prime[1] := false;
+
+  for i := 2 to 70 do
+    if prime[i] then
+      for j := 2 to 4999 div i do
+        prime[i * j] := false;
+
+  for i := 1 to 4999 do
+    if prime[i] then
+      writeln(i);
+
+  assign(f, 'BAI1.INP');
+  reset(f);
+
+  readln(f, n, k);
+
+  j := 0;
+  for i := 1 to n do
+    begin
+      read(f, a);
+      if (a < k) and
+         prime[a] then
+        inc(j)
+    end;
+
+  close(f);
+
+  assign(f, 'BAI1.OUT');
+  rewrite(f);
+  writeln(f, j);
+  close(f)
+end.