Codeforces 274A k-multiple Free Set

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.