F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Help the vendor and get some M ^_^

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 570    Accepted Submission(s): 222


Problem Description
A doll vendor has just received a shipment of dolls from the factory. The vendor can only sell dolls in pairs, and have to ensure that in each pair one doll is K times as large as the other. What is the maximum number of pairs that the vendor can assemble? Each doll can only be sold one time. Now the vendor wants your help to solve this problem. Of course, he will give you 30% of the profit, so, what are you waiting for?
 

Input
There are multiple test cases.For each case the input contains two integers N (1<=50<=N) and K (1<=K<=25) in first line and N doll sizes (integers between 1 and 100000, inclusive) below, where N is the number of dolls. The doll sizes may separated by white spaces or newline.Input ends when N and K is 0.
 

Output
For each case, output the maximum number of pairss that the vendor can assemble in one line.
 

Sample Input
5 2 1 2 1 2 4 0 0
 

Sample Output
2 Hint: you can sell two pairs at most, {(1,2),(1,2)} or {(1,2),(2,4)}.
 

Author
scnu
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 12:19:17, Gzip enabled