CF1163C1.Power Transmission (Easy Edition)

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This problem is same as the next one, but has smaller constraints.

It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system consisting of many chimneys, electric poles, and wires. Since they are cats, they found those things gigantic.

At the entrance of the station, there is a map describing the complicated wiring system. Selena is the best at math among three friends. He decided to draw the map on the Cartesian plane. Each pole is now a point at some coordinates (xi,yi)(x_i, y_i). Since every pole is different, all of the points representing these poles are distinct. Also, every two poles are connected with each other by wires. A wire is a straight line on the plane infinite in both directions. If there are more than two poles lying on the same line, they are connected by a single common wire.

Selena thinks, that whenever two different electric wires intersect, they may interfere with each other and cause damage. So he wonders, how many pairs are intersecting? Could you help him with this problem?

本题与下一题相同,但约束条件更小。

某个周日早晨,三位朋友赛琳娜(Selena)、史洛(Shiro)和凯蒂(Katie)决定去附近的发电站游玩(切勿在家模仿)。抵达发电站后,猫咪们被庞大的电力传输系统所震撼——系统中包含众多烟囱、电线杆和导线。由于它们是猫,因此觉得这些设施无比巨大。

在电站入口处,有一张地图详细描述了复杂的布线系统。赛琳娜是三人中数学最好的一位,她决定将这张地图绘制在笛卡尔平面上。每根电线杆现在对应平面上的一个点,其坐标为 (xi,yi)(x_i, y_i)。由于每根电线杆均不相同,因此所有表示电线杆的点互不重合。此外,任意两根电线杆之间均通过导线相连。导线是平面上一条向两端无限延伸的直线。若有多于两根电线杆共线,则它们由同一条导线连接。

赛琳娜认为,每当两条不同的电线相交时,就可能相互干扰并造成损害。因此她想知道:共有多少对电线相交?你能帮她解决这个问题吗?

输入格式

The first line contains a single integer nn (2≤n≤502 \le n \le 50) — the number of electric poles.

Each of the following nn lines contains two integers xix_i, yiy_i (−104≤xi,yi≤104-10^4 \le x_i, y_i \le 10^4) — the coordinates of the poles.

It is guaranteed that all of these nn points are distinct.

第一行包含一个整数 nn(2≤n≤502 \le n \le 50)—— 表示电线杆的数量。

接下来的 nn 行,每行包含两个整数 xix_i、yiy_i(−104≤xi,yi≤104-10^4 \le x_i, y_i \le 10^4)—— 表示第 ii 根电线杆的坐标。

保证这 nn 个点互不相同。

输出格式

Print a single integer — the number of pairs of wires that are intersecting.

输出一个整数——相交的导线对的数量。

输入输出样例

  • 输入#1

    4
    0 0
    1 1
    0 3
    1 2

    输出#1

    14
  • 输入#2

    4
    0 0
    0 2
    0 4
    2 0

    输出#2

    6
  • 输入#3

    3
    -1 -1
    1 0
    3 1

    输出#3

    0

说明/提示

In the first example:

In the second example:

Note that the three poles (0,0)(0, 0), (0,2)(0, 2) and (0,4)(0, 4) are connected by a single wire.

In the third example:

在第一个例子中:

在第二个例子中:

注意,三个桩 (0,0)(0, 0)、(0,2)(0, 2) 和 (0,4)(0, 4) 由一根导线连接。

在第三个例子中:

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

首页