2578.Ruminations on Ruminants

Time Limit: 1s Memory Limit: 256MB

Kevin Sun is ruminating on the origin of cows while standing at the origin of the Cartesian plane. He notices n lines 2578_1.png on the plane, each representable by an equation of the form ax+by=c. He also observes that no two lines are parallel and that no three lines pass through the same point.For each triple (i,j,k) such that 1 \le i \lt j \lt k \le n, Kevin considers the triangle formed by the three lines 2578_2.png . He calls a triangle original if the circumcircle of that triangle passes through the origin. Since Kevin believes that the circles of bovine life are tied directly to such triangles, he wants to know the number of original triangles formed by unordered triples of distinct lines. Recall that the circumcircle of a triangle is the circle which passes through all the vertices of that triangle.

Input Format(From the terminal/stdin)

Input The first line of the input contains a single integer n (3 \le n \le 2000), the number of lines.The next n lines describe lines 2578_3.png. The i-th of these lines contains three space-separated integers ai,bi,ci (|ai|,|bi|,|ci| \le 10000,ai2+bi2 \gt 0), representing the equation aix+biy=ci of line 2578_4.png.

Output Format(To the terminal/stdout)

Output Print a single integer, the number of triples (i,j,k) with i \lt j \lt k such that lines 2578_2.png form an original triangle.

Sample Input 1

Copy
4
1 0 0
0 1 0
1 1 -1
1 -1 2
 \n
 · · \n
 · · \n
 · ·  \n
 ·  · \n

Sample Output 1

Copy
2
 \n

Sample Input 2

Copy
3
0 1 1
1 1 2
1 -1 -2
 \n
 · · \n
 · · \n
 ·  ·  \n

Sample Output 2

Copy
1
 \n

Hints

Note that in the first sample, some of the lines pass through the origin.In the second sample, there is exactly one triple of lines: y=1,x+y=2,x-y=-2. The triangle they form has vertices (0,2),(1,1),(-1,1). The circumcircle of this triangle has equation x2+(y-1)2=1. This indeed passes through (0,0).

Submit

请先 登录

© 2025 FAQs