Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let s think you are playing with numbers. You have been given a set of integers as candidatenumbers and an integer as a query number

Lets think you are playing with numbers. You have been given a set of integers as candidatenumbers and an integer as a query number. Now, count the number of 1s (1s count value) inthe binary representations of all the candidate and query numbers. Then, you have to figure outtwo numbers from the candidate numbers set-I. One numbers 1s count value must have a minimum difference from the 1s countvalue of the query number.II. Another numbers 1s count value must have a maximum difference from the 1s countvalue of the query number.If you find multiple candidate numbers with minimum differences, choose the lowest numberamong them. Again, if multiple numbers can be identified with maximum differences, considerthe 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 querynumber and an integer m (3<= m <=10000) representing how many integer numbers are in theset of candidate numbers. The next line contains m positive integer numbers separated bywhite spaces. Those integers represent the elements of the candidate numbers set, and eachnumber 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, youmust show the case number at the beginning. Then, (m+1) lines will show the binaryrepresentations of the candidate numbers and the query number in 32 bits. Finally, print twodesired numbers (stated in the Problem Statement section) as output.Restrictions:You cannot use one/multi-dimensional arrays or any other data structures. You also cannotcall any self-implemented or built-in functions (except 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

Step: 3

blur-text-image

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions