Integer Game
Time limit2sMemory limit512 MB
Given N and up to 15 divisors, remove multiples of each in order and count how many numbers from 1 to N survive.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Combinatorics, Bit manipulation
- Solved
- No attempts yet
Problem
Jaehyun plays an integer game with the following rules.
- Fix an integer and an array of length .
- Write every integer from to on a sheet of paper.
- Take the first number of and remove it from the array. Calling that number , erase every multiple of written on the paper.
- Repeat step 3 until the array is empty.
Write a program that counts how many numbers are still written on the paper after the game ends.
Input
The first line contains and . (, )
The second line contains the elements of in order. Each element is a natural number at most , and the same number may appear more than once.
Output
Print on the first line how many numbers are still written on the paper after the game ends.
Hint
If is and the array is , you erase the multiples of , then of , then of , and the paper keeps , , and .