-->
当前位置:首页 > 题库

PROGRAMMING:Nearest neighbor

Luz5年前 (2021-05-10)题库438
In a non descending sequence, find the element closest to the given value.
###Input format:
The first line contains two numbers, an integer n, representing the number of elements in the sequence( 1 ≤ n ≤ 1000000。), An integer x to find the nearest neighbor of X.
The second line contains n integers, which are elements of non descending sequence. The size of all elements is between 1 and 1e9.
###Output format:
An integer that is the element value closest to the corresponding given value. If more than one value satisfies the condition, output the smallest one.
###Input example:
Here is a set of inputs. For example:
```in
3 6
2 5 8
```
###Output example:
```out
five
```







answer:If there is no answer, please comment