Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

What is the background of the situation?

Answered: 1 week ago