QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 1024 MB 총점: 100

#23875. 最近的值

통계

題目描述

給定整數 $X, L, R$。在 $L$ 以上 $R$ 以下的整數中,輸出與 $X$ 之差的絕對值最小的那個整數。可以證明這樣的整數恰好只存在 $1$ 個。

資料範圍

  • $1 \le X \le 100\,000$。
  • $1 \le L \le R \le 100\,000$。

輸入格式

輸入從標準輸入按以下格式給出:

X L R

輸出格式

在 $L$ 以上 $R$ 以下的整數中,輸出與 $X$ 之差的絕對值最小的那個整數。

範例 1

輸入

8 3 6

輸出

6

在 $3, 4, 5, 6$ 中,與 $8$ 之差的絕對值最小的是 $6$。因此輸出 $6$。

範例 2

輸入

7 3 10

輸出

7

在 $3, 4, 5, 6, 7, 8, 9, 10$ 中,與 $7$ 之差的絕對值最小的是 $7$。因此輸出 $7$。

範例 3

輸入

8 10 10

輸出

10

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.