Question
Mike , intelligent person , challenges his friend suzan with a mathematics task. Whereas, Mike has a list of integers Number N and he has
Mike , intelligent person , challenges his friend suzan with a mathematics task. Whereas, Mike has a list of integers Number N and he has another integer number S . Mike challenges suzan in whether it is possible to obtain the first two numbers in the list, the sum of which is equal to the number S, S = 8 represent the sum of first two number in list , N = 4 is the number of elements in the list . List = 4 5 3 4 , from this ex: first two number = 5 3 .
Input Format
first line there will be an integer number T (number of test cases) followed by 2 input lines for each test case: On the first line of each test case, there will be 2 integers S and N, where S is the expected sum and N is the number of elements in the list. On the second line, there will list of number .
Constraints
1T1000
Output Format
If there is an unique solution: Write two elements, x and y of the list List , such that x+y = S and xy. If there is no solution: Print the error message !NO
Sample Input 0
6 8 4 1 2 4 4 8 4 1 2 7 9 8 4 1 2 8 9 8 4 4 5 3 4 8 4 4 1 1 8 8 4 -1 1 9 8
Sample Output 0
4 4 1 7 !NO 3 5 !NO -1 9
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