Question: Problem Statement: Let s think you are playing with numbers. You have been given a set of integers as candidate numbers and an integer as

Problem Statement:
Lets think you are playing with numbers. You have been given a set of integers as candidate
numbers and an integer as a query number. Now, count the number of 1s (1s count value) in
the binary representations of all the candidate and query numbers. Then, you have to figure out
two numbers from the candidate numbers set-
I. One numbers 1s count value must have a minimum difference from the 1s count
value of the query number.
II. Another numbers 1s count value must have a maximum difference from the 1s count
value of the query number.
If you find multiple candidate numbers with minimum differences, choose the lowest number
among them. Again, if multiple numbers can be identified with maximum differences, consider
the highest number among them.
Input:
Take an integer n (1<= n <=1000) as input, representing the total test cases.
Each case starts with a positive integer k (1<= k <4,294,967,296) indicating the query
number and an integer m (3<= m <=10000) representing how many integer numbers are in the
set of candidate numbers. The next line contains m positive integer numbers separated by
white spaces. Those integers represent the elements of the candidate numbers set, and each
number will be between 1 and 4,294,967,295.
Output:
Output should be organized as in the sample shown on the next page. For each test case, you
must show the case number at the beginning. Then, (m+1) lines will show the binary
representations of the candidate numbers and the query number in 32 bits. Finally, print two
desired numbers (stated in the Problem Statement section) as output.
Restrictions:
You cannot use one/multi-dimensional arrays or any other data structures. You also cannot call any selfimplemented or built in founctions excepts scanf and printf

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!