Four Multiples
How many integers in [1,n] are divisible by at least one of the four positive integers a, b, c, and d?
Print the exact count (not modulo anything).
Input
A single line containing five integers n, a, b, c, and d.
Output
Print one integer: the number of integers in [1,n] that are divisible by at least one of a, b, c, and d.
Constraints
- 1≤n≤1018
- 1≤a,b,c,d≤109
Example 1
10 2 3 5 7
9
Explanation
The integers in [1,10] divisible by 2, 3, 5, or 7 are 2,3,4,5,6,7,8,9,10. Only 1 is missing.
Example 2
1 2 3 4 5
0
Explanation
The only candidate is 1, and none of 2,3,4,5 divide 1.
Example 3
100 2 2 2 2
50
Explanation
All four moduli are 2, so the answer is the number of even integers in [1,100].
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.