AdvancedRating 1700
Divisible by Any of These Primes
Count the numbers from 1 to n divisible by at least one of the given distinct primes. Use inclusion–exclusion.
Input
n (≤ 10¹⁸) and k (≤ 15), then k primes.
Output
One integer.
Sample 1
Input
20 2 2 3
Output
13
Sample 2
Input
100 3 2 3 5
Output
74
Output appears here