A k-multiple free set was a set of integers where there is no pair of integers where one was equal to another integ Er multiplied by k. That's, there is no integers x and y (x<? Y) from the set, such that y? =? X· k.
You ' re given a set of n distinct positive integers. Your task is to find the size of it's largest k-multiple free subset.
Input
The first line of the input contains the integersNandk(1?≤? n? ≤?105,? 1?≤? k. ≤?109 ). The next line contains a list ofNDistinct positive integers a1,? a 2,?...,? a N (1?≤? ) Ai? ≤?109).
All of the numbers in the lines is separated by a single spaces.
Output
On the same line of the output print the size of the largest K-multiple free subset of {a1, ? a 2,?...,? a N}.
Sample Test (s)
Input
6 22 3 6 5 4 10
Output
3
Note
The sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.
Enter N,k. and a to find the length of the longest continuous non-K-fold sequence in a
Need to be aware of timeouts
# coding=utf-8n, k = list (map (int, input (). Split ("))) A = list (map (int, input (). Split ("))) A.sort () s = []d = {}m = 0for I in A:If i% k! = 0:s.append (i) d[i] = 1 m + = 1 elif (I//k) not in D:s.append (i) D[i] = 1 m + = 1print (m)
Codeforces 274A k-multiple Free Set