Mobile coding works. A laptop is faster for long sessions.
Problem
The program reads from standard input five integers `a`, `b`, `c`, `L`, `R`, separated by spaces. Consider the expression:
`f(x) = a * x * x + b * x + c`
Compute the minimum value that `f` takes when `x` ranges over every integer in the interval `[L, R]`, and print:
- first, the value `x` at which this minimum is achieved (if there are several, print the smallest);
- then, separated by a space, the minimum value `f(x)`.
Input format
Input
input.txt
The program reads from standard input on a single line the five numbers: `a b c L R`. - `-1000 <= a, b, c <= 1000` - `-1000 <= L <= R <= 1000` - All intermediate values fit in `long long`.
Output format
Output
output.txt
The program prints to standard output on a single line two integers: `x` and `f(x)`, separated by a space.
Example
input
1 -4 5 0 10
output
2 1
Stuck?
Use the Get Hint button in the action bar to reveal a guided hint.
💬 Discussion
Loading...💬
No comments yet. Be the first to start the discussion!
💻 No output yet.
Click Run in the editor to execute your code with the custom input.
Sample cases (from the problem)
Sample Case 1
Input
1 -4 5 0 10
Expected output
2 1
Solve it your way first
Community solutions unlock after you submit a passing solution. Don't peek.
Ready to solve this challenge?
Create a free account to write code, submit solutions, and track your progress.
⌨️ Keyboard Shortcuts
Code Editor
Run Code
Ctrl
Enter
Submit Code
Ctrl
Shift
Enter
Format Code
Shift
Alt
F
Toggle Comment
Ctrl
/
Undo
Ctrl
Z
Redo
Ctrl
Y
Navigation
Global Search
/
Show Shortcuts
?
Close Modal
Esc