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.