N the number of marbles and Q the number of queries Mina would make. The next N lines would contain the numbers written on the N marbles. These marble numbers will not come in any particular order. Following Q lines will have Q queries. Be assured, none of the input numbers are greater than 10000 and none of them are negative.
Input is terminated by a test case where N = 0 and Q = 0.
For each of the queries, print one line of output. The format of this line will depend upon whether or not the query number is written upon any of the marbles. The two different formats are described below:
- `x found at y', if the first marble with number x was found at position y. Positions are numbered 1, 2,..., N.
- `x not found', if the marble with number x is not present.
4 1 2 3 5 1 5 5 2 1 3 3 3 1 2 3 0 0
CASE# 1: 5 found at 4 CASE# 2: 2 not found 3 found at 3
Solution:Sort the array, then use the binary search to find the lower bound of the search key.
The condition statement is the key part here.