about summary refs log tree commit diff
path: root/12/TP-ThanhHoá-2009/bai1.pas
blob: 511d074ba2a074cbb4e8a980a6aaccfa9969558f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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.