#P2950. [USACO09OPEN] Bovine Embroidery G
[USACO09OPEN] Bovine Embroidery G
Description
Bessie has taken up the detailed art of bovine embroidery. Cows embroider a cloth mounted in a circular hoop of integer radius (). They sew () straight threads, each from one point on the edge of the hoop to another point on the edge (no two embroidered points share a location on the hoop's edge).
Being mathematically inclined, Bessie knows a formula of the form for each straight thread. Conveniently, , , and are integers (, , ). Even more conveniently, no two threads coincide exactly. At least one of and is non-zero for each thread’s formula.
Perhaps less conveniently, Bessie knows that her set of formula coefficients also includes some lines that do not pass through the interior of the hoop’s circle. The origin is at the exact center of the hoop, so all points on the hoop’s edge are at distance from the origin.
Bovine embroidery is more highly regarded when the number of thread intersections is maximized. Help Bessie count the number of pairs of threads that intersect on the cloth, i.e., whose intersection point lies within distance of the origin. If threads meet at the same point inside the circle, they contribute pairs (e.g., three threads give three pairs; four threads give six pairs).
Input Format
- Line 1: Two space-separated integers and .
- Lines 2 to : Line describes thread with three integers: , , and .
Output Format
- Line 1: One integer, the count of pairs of threads that intersect inside the circle of radius .
2 1
1 0 0
0 1 0
1
Hint
The two lines are and . The two lines intersect at , which is clearly within distance of the origin.
Translated by ChatGPT 5
京公网安备 11011102002149号