Multiples of Primes
InterviewTime limit0.25sMemory limit512 MB
Given up to 10 distinct primes and a limit M up to 1e12, count the natural numbers at most M divisible by at least one listed prime.
- Level
Medium7 of 10
- Topics
- Combinatorics, Math, Number theory, Bit manipulation
- Solved
- No attempts yet
Problem
You are given primes and a natural number . Among the natural numbers not exceeding , count how many are divisible by at least one of the primes.
Input
The first line contains () and (). The second line contains primes. Each given prime is at most , and no prime appears more than once.
Output
Print the number of natural numbers not exceeding that are divisible by at least one of the primes.