Блог пользователя nayeem2021

Автор nayeem2021, история, 3 года назад, По-английски

[It's a help seeking post.]

We have an array a of size n(n<=10^5) and a number k(k<=10^10). How can we find the number of integers between 1 to k (including 1 and k) which are divisible by at least one element of a

Example:

10 49 20 30 40 [the array a]

50 [the number k]

Answer

6

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

maybe betwen 1 to k instead 1 to n?

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Maybe using inclusion-exclusion principle? Not fully sure how but feels like it.

»
3 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

For the sample isn't the answer 6? Because there's 10, 20, 30, 40, 49, 50