Diferente pentru problema/sieve2 intre reviziile #1 si #3

Nu exista diferente intre titluri.

Diferente intre continut:

== include(page="template/taskheader" task_id="sieve2") ==
Poveste şi cerinţă...
Giorgio is playing with the Sieve of Eratosthenes, one of the most ancient algorithms of all times. This algorithm starts with a row of all numbers from $2$ to $M$, then repeatedly selects the smallest non-selected number remaining in the row, erasing every multiple of it. At the end of the process, only prime numbers will have survived in the row!
 
Giorgio is trying to apply a similar idea, but with few differences.  Firstly, some numbers are missing from the starting row, which contains only $N$ numbers overall (each of them between $2$ and $M$), in increasing order. Secondly, every time Giorgio selects a number, he erases not only the multiples of it but also its divisors. As in the original algorithm, Giorgio keeps selecting numbers from the row (end erasing accordingly), stopping when every remaining number has been already selected; but he doesn't have to select numbers in increasing order. How many numbers can remain at the end of the process, at minimum?
h2. Date de intrare
Fişierul de intrare $sieve2.in$ ...
The first line of the input file $sieve2.in$ contains $N$ and $M$. The second line of the input contains the $N$ integers in increasing order.
h2. Date de ieşire
În fişierul de ieşire $sieve2.out$ ...
The output file $sieve2.out$ will contain a single line with an integer: the minimum amount of numbers that must remain at the end of the process.
h2. Restricţii
* $... ≤ ... ≤ ...$
* $1 ≤ N ≤ 250$
* $1 ≤ M ≤ 10^6$
* For tests worth $35$ points, $1 ≤ N ≤ 9$
* For tests worth $15$ more points, $1 ≤ M ≤ 20$
* For tests worth $20$ more points, $1 ≤ N ≤ 50$
h2. Exemplu
table(example). |_. sieve2.in |_. sieve2.out |
| This is some
  text written on
  multiple lines.
| This is another
  text written on
  multiple lines.
| 6 10
3 4 6 7 8 9
| 3
|
 
table(example). |_. sieve2.in |_. sieve2.out |
| 6 20
2 5 7 10 14 20
| 2
|
h3. Explicaţie
...
In the first sample case, one of the best strategies is to choose numbers $7$, $3$ and $4$. Suboptimal solutions exist, such as choosing numbers $9$, $8$, $7$ and $6$.
 
In the second sample case, one of the best strategies is to choose numbers $20$ and $14$.
== include(page="template/taskfooter" task_id="sieve2") ==

Nu exista diferente intre securitate.

Topicul de forum nu a fost schimbat.