Under construction

Still being built. Things may change

Smallest Calculated Value

Time limit1sMemory limit1024 MB

Summary
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, 9/39/3 is okay, 10/310/3 is not.

For example:

For 22, 33 and 55, the answer is 00 (2+3−52+3-5)

For 99, 99 and 99, the answer is 00 (9−9 / 99-9\ /\ 9)

For 55, 77 and 33, the answer is 11 (5−7+35-7+3)

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 11 to 1,0001{,}000.

Output

Output a single integer, which is the smallest non-negative value possible when applying the arithmetic operators.

Examples3

  1. Example 1

    Input
    2 3 5
    
    Expected output
    0
    
  2. Example 2

    Input
    9 9 9
    
    Expected output
    0
    
  3. Example 3

    Input
    5 7 3
    
    Expected output
    1