atcoder#AGC057F. [AGC057F] Reflection
[AGC057F] Reflection
Score : points
Problem Statement
There are three indistinguishable stones at integer coordinates on a number line. Consider the following operation on these stones:
- Let be the three stones in ascending order of coordinate (ties broken arbitrarily). Perform one of the following.- Move to the symmetric position with respect to .
- Move to the symmetric position with respect to .
- Move to the symmetric position with respect to .
- Move to the symmetric position with respect to .
You are given the initial coordinates of the three stones. Find the number, modulo , of possible combinations of coordinates of the three stones after zero or more operations.
Note that the stones are indistinguishable. More strictly speaking, count the possible multisets of coordinates of the three stones.
We will give you test cases; solve each of them.
Constraints
Input
Input is given from Standard Input in the following format:
Each case is in the following format:
Output
Print lines. The -th line should contain the answer for .
6
1 3 5
-2 -2 5
0 1 3
31 41 59
-123456789 0 987654321
-1000000000000000000 0 1000000000000000000
5
2
9
70
182333351
5
For , the five possible combinations of the three stones after operations are:
- , , , , .
The figure below may be helpful.