atcoder#ABC255C. [ABC255C] ±1 Operation 1
[ABC255C] ±1 Operation 1
Score : points
Problem Statement
You are given an integer . The following action on this integer is called an operation.
- Choose and do one of the following.- Add to .
- Subtract from .
The terms in the arithmetic progression with terms whose initial term is and whose common difference is are called good numbers. Consider performing zero or more operations to make a good number. Find the minimum number of operations required to do so.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
6 2 3 3
1
Since , we have . You can subtract from once to make a good number. It is impossible to make good in zero operations.
0 0 0 1
0
We might have . Additionally, no operation might be required.
998244353 -10 -20 30
998244363
-555555555555555555 -1000000000000000000 1000000 1000000000000
444445