Answered step by step
Verified Expert Solution
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 s s count value inthe binary representations of all the candidate and query numbers. Then, you have to figure outtwo numbers from the candidate numbers setI. One numbers s count value must have a minimum difference from the s countvalue of the query number.II Another numbers s count value must have a maximum difference from the s 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 n as input, representing the total test cases.Each case starts with a positive integer k k indicating the querynumber and an integer m m 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 and 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 lines will show the binaryrepresentations of the candidate numbers and the query number in bits. Finally, print twodesired numbers stated in the Problem Statement section as output.Restrictions:You cannot use onemultidimensional arrays or any other data structures. You also cannotcall any selfimplemented or builtin functions except scanf and printf
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started