QOJ.ac

QOJ

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

#23875. Najbliższa wartość

Statistiques

Treść zadania

Dane są liczby całkowite $X, L, R$. Spośród liczb całkowitych od $L$ do $R$ włącznie wypisz tę, dla której wartość bezwzględna różnicy z $X$ jest najmniejsza. Można udowodnić, że istnieje dokładnie $1$ taka liczba całkowita.

Ograniczenia

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

Wejście

Wejście podawane jest ze standardowego wejścia w następującym formacie:

X L R

Wyjście

Spośród liczb całkowitych od $L$ do $R$ włącznie wypisz tę, dla której wartość bezwzględna różnicy z $X$ jest najmniejsza.

Przykład 1

Wejście

8 3 6

Wyjście

6

Spośród $3, 4, 5, 6$ liczbą o najmniejszej wartości bezwzględnej różnicy z $8$ jest $6$. Dlatego należy wypisać $6$.

Przykład 2

Wejście

7 3 10

Wyjście

7

Spośród $3, 4, 5, 6, 7, 8, 9, 10$ liczbą o najmniejszej wartości bezwzględnej różnicy z $7$ jest $7$. Dlatego należy wypisać $7$.

Przykład 3

Wejście

8 10 10

Wyjście

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.