0
点赞
收藏
分享

微信扫一扫

No.20 The Nearest Number

天悦哥 2022-02-20 阅读 42
c++c语言

原文:

The Nearest Number

描述:

Given a sequence of N number and K. Find the nearest number X in the sequence that the absolute value of (X minus K) is minimum.

输入:

First line: two positive integers N (N <= 100) and K (K <= 100000).
Second line: N positive integers (<= 100000).

输出:

One integer X.

样例输入:

4 5
2 4 7 8

样例输出:

4

参考译文:

最接近的数

描述:

给定一个由N个数和K个数组成的序列,找出序列中最接近的X个数(X - K)的绝对值最小。

输入:

第一行包含两个整数N和K。

第二行包含N个整数,用来表示该数列S。

输出:

一个整数X

样例输入:

4 5
2 4 7 8

样例输出:

4
举报

相关推荐

0 条评论