Answered step by step
Verified Expert Solution
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 s s 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 s count value must have a minimum difference from the s count
value of the query number.
II Another numbers s count value must have a maximum difference from the s 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 n as input, representing the total test cases.
Each case starts with a positive integer k k indicating the query
number and an integer m m 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 and
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 lines will show the binary
representations of the candidate numbers and the query number in bits. Finally, print two
desired numbers stated in the Problem Statement section as output.
Restrictions:
You cannot use onemultidimensional 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
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