atcoder#AGC051E. [AGC051E] Middle Point
[AGC051E] Middle Point
Score : points
Problem Statement
Initially, points are plotted on a plane. Snuke is allowed to perform the following operation an arbitrary finite number of times:
- Choose two points that are already plotted, and plot the middle point of the two chosen points (if the middle point hasn't been plotted yet). The coordinates of the middle point don't necessarily have to be integers.
After he finish performing operations, his score is the number of plotted points with integer coordinates (including the initial points). Compute the maximum score he can get.
Constraints
- No three points are on the same line.
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4
0 0
0 2
2 0
2 2
9
One possible way to achieve the maximum score is as follows:
- Initially, four points are plotted.
- Plot : the middle point of and .
- Plot : the middle point of and .
- Plot : the middle point of and .
- Plot : the middle point of and .
- Plot : the middle point of and .
- Plot : the middle point of and .
- Now we have points: $(0, 0), (0, 0.5), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)$. of them have integer coordinates, so the score is .
4
0 0
0 3
3 0
3 3
4
We can prove that, besides the initial points, he can't plot any points with integer coordinates.