CF1468E.Four Segments

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Monocarp wants to draw four line segments on a sheet of paper. He wants the ii-th segment to have its length equal to aia_i (1≤i≤41 \le i \le 4). These segments can intersect with each other, and each segment should be either horizontal or vertical.

Monocarp wants to draw the segments in such a way that they enclose a rectangular space, and the area of that rectangular space should be maximum possible.

For example, if Monocarp wants to draw four segments with lengths 11, 22, 33 and 44, he can do it the following way:

Here, Monocarp has drawn segments ABAB (with length 11), CDCD (with length 22), BCBC (with length 33) and EFEF (with length 44). He got a rectangle ABCFABCF with area equal to 33 that is enclosed by the segments.

Calculate the maximum area of a rectangle Monocarp can enclose with four segments.

Monocarp 想要在一张纸上画四条线段。他希望第 ii 条线段的长度恰好为 aia_i(1≤i≤41 \le i \le 4)。这些线段可以相互相交,且每条线段必须是水平或垂直的。

Monocarp 希望以某种方式画出这四条线段,使得它们围成一个矩形区域,并使该矩形区域的面积尽可能大。

例如,若 Monocarp 想画四条长度分别为 11、22、33 和 44 的线段,则可按如下方式绘制:


图中,Monocarp 绘制了线段 ABAB(长度为 11)、CDCD(长度为 22)、BCBC(长度为 33)和 EFEF(长度为 44)。由此得到被这些线段围成的矩形 ABCFABCF,其面积为 33。

请计算 Monocarp 能用四条线段围成的最大矩形面积。

输入格式

The first line contains one integer tt (1≤t≤3⋅1041 \le t \le 3 \cdot 10^4) — the number of test cases.

Each test case consists of a single line containing four integers a1a_1, a2a_2, a3a_3, a4a_4 (1≤ai≤1041 \le a_i \le 10^4) — the lengths of the segments Monocarp wants to draw.

第一行包含一个整数 tt(1≤t≤3⋅1041 \le t \le 3 \cdot 10^4)—— 测试用例的数量。

每个测试用例由一行组成,包含四个整数 a1a_1、a2a_2、a3a_3、a4a_4(1≤ai≤1041 \le a_i \le 10^4)—— Monocarp 想要绘制的线段的长度。

输出格式

For each test case, print one integer — the maximum area of a rectangle Monocarp can enclose with four segments (it can be shown that the answer is always an integer).

对于每个测试用例,输出一个整数——Monocarp 用四条线段所能围成的矩形的最大面积(可以证明答案总是整数)。

输入输出样例

  • 输入#1

    4
    1 2 3 4
    5 5 5 5
    3 1 4 1
    100 20 20 100

    输出#1

    3
    25
    3
    2000

说明/提示

The first test case of the example is described in the statement.

For the second test case, Monocarp can draw the segments ABAB, BCBC, CDCD and DADA as follows:

Here, Monocarp has drawn segments ABAB (with length 55), BCBC (with length 55), CDCD (with length 55) and DADA (with length 55). He got a rectangle ABCDABCD with area equal to 2525 that is enclosed by the segments.

示例中的第一个测试用例已在题面中描述。

对于第二个测试用例,Monocarp 可按如下方式绘制线段 ABAB、BCBC、CDCD 和 DADA:


此处,Monocarp 绘制了线段 ABAB(长度为 55)、BCBC(长度为 55)、CDCD(长度为 55)和 DADA(长度为 55)。他由此得到一个矩形 ABCDABCD,其面积为 2525,且该矩形被这些线段所围成。

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

首页