CF1466A.Bovine Dilemma

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Argus was charged with guarding Io, which is not an ordinary cow. Io is quite an explorer, and she wanders off rather frequently, making Argus' life stressful. So the cowherd decided to construct an enclosed pasture for Io.

There are nn trees growing along the river, where Argus tends Io. For this problem, the river can be viewed as the OXOX axis of the Cartesian coordinate system, and the nn trees as points with the yy-coordinate equal 00. There is also another tree growing in the point (0,1)(0, 1).

Argus will tie a rope around three of the trees, creating a triangular pasture. Its exact shape doesn't matter to Io, but its area is crucial to her. There may be many ways for Argus to arrange the fence, but only the ones which result in different areas of the pasture are interesting for Io. Calculate the number of different areas that her pasture may have. Note that the pasture must have nonzero area.

阿耳戈斯受命看守伊俄,而伊俄并非一头普通的母牛。伊俄颇具探险精神,常常四处游荡,这让阿耳戈斯的生活倍感压力。因此,牧牛人决定为伊俄建造一处封闭的牧场。

沿河生长着 nn 棵树,阿耳戈斯正是在此处照看伊俄。在本题中,可将河流视为笛卡尔坐标系中的 OXOX 轴,而这 nn 棵树则对应于 yy 坐标为 00 的点(即均位于 xx 轴上)。此外,在点 (0,1)(0, 1) 处还生长着另一棵树。

阿耳戈斯将用绳子围绕其中三棵树围成一个三角形牧场。牧场的具体形状对伊俄而言并不重要,但其面积却至关重要。阿耳戈斯可能有多种方式布置围栏,但只有那些产生不同牧场面积的方式才令伊俄感兴趣。请计算她的牧场可能具有的不同面积的个数。注意:牧场面积必须非零。

输入格式

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤1001 \leq t \leq 100) — the number of test cases. Then tt test cases follow, each one is described in two lines.

In the first line of each test case there is a single integer nn (1≤n≤501 \leq n \leq 50) denoting the number of trees growing along the river. Next line contains nn distinct integers x1<x2<…<xn−1<xnx_1 \lt x_2 \lt \ldots \lt x_{n - 1} \lt x_n (1≤xi≤501 \leq x_i \leq 50), the xx-coordinates of trees growing along the river.

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100),表示测试用例的数量。随后是 tt 个测试用例,每个测试用例由两行描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤501 \leq n \leq 50),表示沿河生长的树的数量。第二行包含 nn 个互不相同的整数 x1<x2<…<xn−1<xnx_1 \lt x_2 \lt \ldots \lt x_{n - 1} \lt x_n(1≤xi≤501 \leq x_i \leq 50),表示沿河生长的树的 xx-坐标。

输出格式

In a single line output an integer, the number of different nonzero areas that triangles with trees as vertices may have.

在一行中输出一个整数,表示以树木为顶点的三角形可能具有的不同非零面积的个数。

输入输出样例

  • 输入#1

    8
    4
    1 2 4 5
    3
    1 3 5
    3
    2 6 8
    2
    1 2
    1
    50
    5
    3 4 5 6 8
    3
    1 25 26
    6
    1 2 4 8 16 32

    输出#1

    4
    2
    3
    1
    0
    5
    3
    15

说明/提示

In the first test case, we have 66 non-degenerate triangles with the following areas: 0.50.5, 0.50.5, 11, 1.51.5, 1.51.5 and 22. The pasture can have 44 different areas, and thus 44 is the answer.

In the second test case, we have 33 non-degenerate triangles with the following areas: 11, 11 and 22. The pasture can have 22 different areas, so 22 is the answer.

The following two drawings present the situation in the second test case. The blue triangles in the first drawing have area 11. The red triangle in the second drawing has area 22.

在第一个测试用例中,我们有 66 个非退化三角形,其面积分别为:0.50.5、0.50.5、11、1.51.5、1.51.5 和 22。牧场可能具有 44 种不同的面积,因此答案为 44。

在第二个测试用例中,我们有 33 个非退化三角形,其面积分别为:11、11 和 22。牧场可能具有 22 种不同的面积,因此答案为 22。

以下两张图展示了第二个测试用例的情形。第一张图中的蓝色三角形面积为 11;第二张图中的红色三角形面积为 22。

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

首页