Atenţie! Aceasta este o versiune veche a paginii, scrisă la 2022-01-13 20:41:05.
Revizia anterioară   Revizia următoare  

 

Fişierul intrare/ieşire:sieve2.in, sieve2.outSursăIIOT 2021-22 Runda 3
AutorGiorgio AudritoAdăugată destefdascalescuStefan Dascalescu stefdascalescu
Timp execuţie pe test1 secLimită de memorie131072 kbytes
Scorul tăuN/ADificultateN/A

Vezi solutiile trimise | Statistici

Sieve2

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 V_0, \ldots, V_{N-1}. Secondly, every time Giorgio selects a number, he erases not only the \emph{multiples} of it but also its \emph{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?

Date de intrare

Fişierul de intrare sieve2.in ...

Date de ieşire

În fişierul de ieşire sieve2.out ...

Restricţii

  • ... ≤ ... ≤ ...

Exemplu

sieve2.insieve2.out
This is some
text written on
multiple lines.
This is another
text written on
multiple lines.

Explicaţie

...

Trebuie sa te autentifici pentru a trimite solutii. Click aici

Cum se trimit solutii?