Minho's number game
Time limit2sMemory limit512 MB
Count integers from 1 to N divisible by at least one of up to 20 given numbers, where duplicates and multiples make plain unions invalid.
- Level
Medium7 of 10
- Topics
- Combinatorics, Number theory, Math, Bit manipulation
- Solved
- No attempts yet
Problem
Minho has cards. Each card has one positive integer written on it. Minho made up a number game with them.
The game is to count how many positive integers from 1 to are divisible by at least one of the numbers written on the cards.
There are far too many numbers to count by hand. Count them for Minho.
Input
The first line contains and , separated by a space. (, )
The second line contains the numbers written on the cards, , in order and separated by spaces. ()
Several cards may carry the same number.
Output
Print on one line how many positive integers from 1 to are divisible by at least one of the numbers written on the cards.