IITKWPCO - Create Collections

  Little Feluda likes to play very much. As you know he only plays with numbers. So he is given n numbers. Now tries to group the numbers into disjoint collections each containing two numbers. He can form the collection containing two numbers iff small number in the collection is exactly half of large number.

  Given n numbers, Find out how many maximum number of collections he can form ?


T: number of test cases. (1 <= T <= 100).

For each test case:

First line will contain n :  (1 <= n <= 100)

Then next line will contain n numbers single space seperated. Range of each number will be between 1 and 10^6.


For each test case, output maximum number of collections that can be formed.


1 2
1 2 4

hide comments
vineetpratik: 2016-07-04 12:25:03

just take care of repetition, easy using map :)

pvsmpraveen: 2016-06-27 14:16:48

Never forget to .clear() something after each test case ;)

mkfeuhrer: 2016-06-21 23:03:55

simple hashing !! AC in 1 go :-) take 10^7 size and use scanf...!

gkr007: 2016-06-02 16:30:05

@kp ur test case really helped ;)

atulsinha007: 2016-01-31 07:40:11

nice and easy one.. though 2 WA's :(

goyal: 2015-07-19 12:39:05

AC:) using maps

Anmol Pandey: 2015-01-24 23:47:37

To those getting WA or Runtime Error
1)range is not in 10^6 it is around 10^7
2)try changing cin to scanf
there isn't any trick involved.

||N0VICE||: 2014-08-18 10:16:30

No need to think too
much my n^2 soln got AC in 0.0s

Last edit: 2014-08-18 10:17:13
Akshay Kamthan: 2014-08-17 07:27:17

wooh! AC in one go for the second time ;):P

Added by:praveen123
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Resource:IITK ACA CSE online judge