QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB Points totaux : 100

#23875. The Nearest Value

Statistiques

Problem Statement

You are given integers $X, L, R$. Among the integers between $L$ and $R$, inclusive, output the one whose absolute difference with $X$ is the smallest. It can be proved that there is exactly $1$ such integer.

Constraints

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

Input

The input is given from Standard Input in the following format:

X L R

Output

Among the integers between $L$ and $R$, inclusive, output the one whose absolute difference with $X$ is the smallest.

Sample 1

Input

8 3 6

Output

6

Among $3, 4, 5, 6$, the one with the smallest absolute difference with $8$ is $6$. Therefore, output $6$.

Sample 2

Input

7 3 10

Output

7

Among $3, 4, 5, 6, 7, 8, 9, 10$, the one with the smallest absolute difference with $7$ is $7$. Therefore, output $7$.

Sample 3

Input

8 10 10

Output

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.