CF603D.Ruminations on Ruminants

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Kevin Sun is ruminating on the origin of cows while standing at the origin of the Cartesian plane. He notices n lines 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 . 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.

凯文·孙正站在笛卡尔平面的原点处,思考着奶牛的起源。他注意到平面上有 nn 条直线,每条直线均可表示为形如 ax+by=cax + by = c 的方程。他还观察到:任意两条直线均不平行,且任意三条直线不共点。

对于每个满足 1≤i<j<k≤n1 \le i < j < k \le n 的三元组 (i,j,k)(i, j, k),凯文考虑由三条直线 Li,Lj,LkL_i, L_j, L_k 所构成的三角形。若该三角形的外接圆经过原点,则称其为原始三角形(original triangle)。由于凯文相信牛的生命之圆与这类三角形直接相关,他希望知道由所有互异直线的无序三元组所构成的原始三角形的个数。

回顾:三角形的外接圆是指经过该三角形所有三个顶点的圆。

输入格式

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

The next n lines describe lines . 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 .

输入的第一行包含一个整数 nn(3≤n≤20003 \leq n \leq 2000),表示直线的数量。

接下来的 nn 行描述了直线 。其中第 ii 行包含三个用空格分隔的整数 ai, bi, cia_i,\ b_i,\ c_i(∣ai∣, ∣bi∣, ∣ci∣≤10 000|a_i|,\ |b_i|,\ |c_i| \leq 10\,000,且 ai2+bi2>0a_i^2 + b_i^2 > 0),表示直线 的方程 aix+biy=cia_i x + b_i y = c_i。

输出格式

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

输出一个整数,表示满足 i<j<ki < j < k 且直线 构成原点三角形的三元组 (i, j, k)(i,\,j,\,k) 的个数。

输入输出样例

  • 输入#1

    4
    1 0 0
    0 1 0
    1 1 -1
    1 -1 2

    输出#1

    2
  • 输入#2

    3
    0 1 1
    1 1 2
    1 -1 -2

    输出#2

    1

说明/提示

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).

注意,在第一个样例中,某些直线经过原点。

在第二个样例中,恰好存在一组三条直线:y=1y = 1,x+y=2x + y = 2,x−y=−2x - y = -2。它们构成的三角形的顶点为 (0,2)(0, 2)、(1,1)(1, 1)、(−1,1)(-1, 1)。该三角形的外接圆方程为 x2+(y−1)2=1x^2 + (y - 1)^2 = 1。该圆确实经过点 (0,0)(0, 0)。

输入解题思路,AI测评打分。不知道怎么写?

首页