Smallest Calculated Value
Time limit1sMemory limit1024 MB
Given three integers, the task is to find the smallest non-negative value from placing one of four operators between each pair, evaluated left to right, with exact division only.
- Level
Easy3 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Problem
Given three integers and the arithmetic operators (, , , ), determine the smallest non-negative integer possible without changing the order of the initial integers. The operators are applied left to right, without their normal precedence. Note: integer division is fine only if the remainder is zero. For example, is okay, is not.
For example:
For , and , the answer is ()
For , and , the answer is ()
For , and , the answer is ()
Given three integers, determine the smallest non-negative result that can be computed by placing the given operators between the numbers. The operators may only be placed between numbers, not in front, so they are not unary operators. An operator must be placed between each pair of adjacent numbers. Numbers cannot be concatenated.
Input
The single line of input contains three integers, all in the range from to .
Output
Output a single integer, which is the smallest non-negative value possible when applying the arithmetic operators.