The Nearest Value to X
InterviewTime limit2sMemory limit512 MB
Given X, L, and R, print the integer in [L, R] whose absolute difference from X is smallest.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
You are given integers X, L, and R. Among the integers between L and R inclusive, output the one whose absolute difference from X is the smallest. It can be proven that exactly one such integer exists.
Input
The input is given on standard input in the following format.
X L R
Output
Among the integers between L and R inclusive, output the one whose absolute difference from X is the smallest.
Constraints
1 ≤ X ≤ 100 000.1 ≤ L ≤ R ≤ 100 000.