Голодные гусеницы
От: sergey2b ЮАР  
Дата: 04.10.15 18:24
Оценка:
Здравствуйте, sjukov, Вы писали:

так как у нас образовался клуб любителей hackerrun которые не быдлокодят формочки
вопрос с моего собеседования на hackerrun на решение дели 15 минут
если надо могу пояснить условие задачи




K caterpillars are eating their way through N leaves. Each caterpillar falls from leaf to leaf in a unique sequence. All caterpillars start at a twig in position 0 and fall onto the leaves at positions between 1 and N. Each caterpillar i has an associated 'jump-number' Ai. A caterpillar with jump number j eats leaves at positions that are multiples of j. It will proceed in the order j, 2j, 3j, ... till it reaches the end of the leaves, then it stops and builds it cocoon.



Given a set A of K elements, we need to determine the number of uneaten leaves.



Input Format:

N = number of leaves
K = number of caterpillars

A = Array of integer jump numbers (one per line).



Constraints:

1 < N < 10^9

1 < K < 15

1 < A[i] < 10^9

Output Format:

Print an integer denoting the number of uneaten leaves.

Sample Input:

10
3
2
4

5

Sample Output:

4

Explanation: [2,4,5] is the 3-member set of jump numbers. All leaves which are multiples of 2, 4, and 5 are eaten. Only 4 leaves which are numbered 1,3,7,9 are left.


05.10.15 05:19: Ветка выделена из темы Hackerrun test
Автор: sjukov
Дата: 26.09.15
— kaa.python
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.