No.1946 Locker Problem
Problem Statement
A school has $N$ students and $N$ lockers numbered from $1$ to $N$.
All the lockers are initially closed.
The $N$ students were instructed to operate the lockers one at a time, in order, according to the following rule.
Rule: The $i$-th student, for each locker whose number is a divisor of $i$, closes it if it is open and opens it if it is closed.
However, it has been reported that some students may have skipped out and not performed any operation at all.
After the operations of the $N$ students were completed, the number of open lockers was $M$, and the numbers of the open lockers were $A_1, A_2, \ldots, A_M$.
The number of students who skipped out is uniquely determined from the numbers of the open lockers. Output the number of students who skipped out.
Input
$N\ M$ $A_1$ $A_2$ $\ldots$ $A_M$
Constraints
- $ 1 \le N \le 2\times10^{5}$
- $ 0 \le M \le N$
- $ 1 \le A_i \le N$
- $A_1 \lt A_2 \lt \ldots \lt A_M$
- All inputs are integers.
Output
Output the number of students who skipped out.
Print a newline at the end.
Sample
Sample 1
Input
6 3 1 2 5
Output
3
The $3$-rd, $4$-th, and $6$-th students skipped out. The open lockers change as follows.
Open lockers after the operation of student $1$: $1$
Open lockers after the operation of student $2$: $2$
Open lockers after the operation of student $5$: $1,2,5$
Sample 2
Input
10 5 2 4 5 8 9
Output
6
It seems that the $1$-st, $2$-nd, $4$-th, $6$-th, $7$-th, and $10$-th students skipped out.
Sample 3
Input
200000 0
Output
200000
It seems that all of the students skipped out.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
H20
蜜蜂
platinum