QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#23875. 가장 가까운 값

Statistics

문제 설명

정수 $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.