Origami Axiom Six: Counting Folds
Time limit1sMemory limit512 MB
Given two point-line pairs, count the distinct fold lines (common tangents of two parabolas) satisfying Huzita's sixth origami axiom for up to 20000 test cases.
- Level
Hard9 of 10
- Topics
- Geometry, Math, Number theory
- Solved
- No attempts yet
Problem
The first formal set of axioms for origami was published by Humiaki Huzita and Benedetto Scimemi and is known as the Huzita axioms. Each axiom describes a way in which a single fold line can be produced by aligning points and lines. One version of the six axioms is:
- Given points and , there is a unique fold passing through both.
- Given points and , there is a unique fold that places onto .
- Given lines and , there is a fold that places onto .
- Given a point and a line , there is a unique fold perpendicular to that passes through .
- Given points , and a line , there is a fold that places onto and passes through .
- Given points , and lines , , there is a fold that places onto and onto .
The sixth axiom is the hard one: a single straight fold must simultaneously reflect onto line and onto line . Depending on the configuration there may be no such fold, or one, two, or three of them.
For each test case, determine how many distinct fold lines satisfy the sixth axiom — that is, how many distinct straight lines reflect onto and onto at the same time.
Input
The first line contains the number of test cases ().
Each test case is given on exactly four lines, describing , , and in that order:
- a line is given by four integers , the coordinates of two distinct points on it;
- a point is given by two integers .
All coordinates are integers with absolute value at most . It is guaranteed that does not lie on and does not lie on . The lines and are different, but the points and may coincide.
Output
For each test case output a single line containing one integer: the number of distinct fold lines that place onto and onto . This value is always , , , or .
Notes
A fold that reflects a point onto a line is exactly a tangent line to the parabola whose focus is and whose directrix is . A fold satisfying the sixth axiom is therefore a common tangent of the parabola and the parabola . Two distinct parabolas share at most three ordinary common tangents, which is why the answer never exceeds three. When and are parallel the number of common tangents can drop to two, one, or zero.