#P44. Middle Point
Middle Point
题目描述
Bobo is exploring a set of lattice points on a two-dimensional plane. Initially, the set of points is defined as . Bobo's goal is to include a specific lattice point in . To achieve the goal, Bobo may perform the following operation:
- Select two lattice points such that is also a lattice point, and add to .
Your task is to help Bobo find a sequence of operations that minimizes the number of steps to achieve the goal or determine if it is impossible to do so.
输入格式
The first line of the input contains two integers and (), describing the parameters of the initial lattice points.
The second line of the input contains two integers and (), denoting the coordinates of the target lattice point.
输出格式
If it is impossible to achieve the goal, output in one line. Otherwise, output a single integer () in one line, denoting the total number of operations to perform. Then lines follow. The -th line contains four integers (), describing the lattice points and chosen in the -th operation. If there exist multiple solutions, output any.
2 2
1 1
1
0 0 2 2
8 8
5 0
3
0 0 8 0
4 0 8 0
4 0 6 0
0 0
0 0
0
2024 0
1012 0
1
0 0 2024 0
2024 2024
2023 2023
-1
8 6
7 3
3
0 0 8 0
4 0 8 0
6 0 8 6
题目大意
给定初始格点集合 ,通过尽可能少的添加中点操作得到格点 。
- 添加中点操作:是指从集合 中选择两个点,得到他们的中点,然后加回集合 。