Codeforces Round 334 (Div. 1)
D
Ruminations on Ruminants
Codeforces
2900
原题
← CE →
翻译中…

Kevin Sun is ruminating on the origin of cows while standing at the origin of the Cartesian plane. He notices $*n*$ lines image 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 ≤ *i* < *j* < *k* ≤ *n*$, Kevin considers the triangle formed by the three lines image . 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

翻译中…

The first line of the input contains a single integer $*n*$ ($3 ≤ *n* ≤ 2000$), the number of lines.

翻译中…

The next $*n*$ lines describe lines image. The $*i*$-th of these lines contains three space-separated integers $*a*_{*i*}, *b*_{*i*}, *c*_{*i*}$ ($|*a*_{*i*}|, |*b*_{*i*}|, |*c*_{*i*}| ≤ 10 000, *a*_{*i*}^{2} + *b*_{*i*}^{2} > 0$), representing the equation $*a*_{*i*}*x* + *b*_{*i*}*y* = *c*_{*i*}$ of line image.

翻译中…

Output

翻译中…

Print a single integer, the number of triples $(*i*, *j*, *k*)$ with $*i* < *j* < *k*$ such that lines image form an original triangle.

翻译中…

Note

翻译中…

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 $*x*^{2} + (*y* - 1)^{2} = 1$. This indeed passes through $(0, 0).$

翻译中…

样例

Input #1
4
1 0 0
0 1 0
1 1 -1
1 -1 2
Output #1
2
InputCopy OutputCopy
Input #2
3
0 1 1
1 1 2
1 -1 -2
Output #2
1
InputCopy OutputCopy
题目信息
题号
603D
时间限制
4 s
内存限制
256 MB
标签
计算几何
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。