Monocarp wants to draw four line segments on a sheet of paper. He wants the ii-th segment to have its length equal to aiai (1≤i≤41≤i≤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.

Input
The first line contains one integer tt (1≤t≤3⋅1041≤t≤3⋅104) — the number of test cases.

Each test case consists of a single line containing four integers a1a1, a2a2, a3a3, a4a4 (1≤ai≤1041≤ai≤104) — the lengths of the segments Monocarp wants to draw.

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

Example
Input
4
1 2 3 4
5 5 5 5
3 1 4 1
100 20 20 100
Output
3
25
3
2000
Note
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.

#include <stdio.h>
int main()
{int n,m,t,a[100],k,i,j,c,b,d;scanf("%d",&m); while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])){for(i=0;i<3;i++){for(j=0;j<3-i;j++){if(a[j]>=a[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;}}}printf("%d\n",a[0]*a[2]);} return 0;
}

D - Four Segments相关推荐

  1. LeetCode刷题记录10——434. Number of Segments in a String(easy)

    LeetCode刷题记录10--434. Number of Segments in a String(easy) 目录 LeetCode刷题记录9--434. Number of Segments ...

  2. codeforces 610D D. Vika and Segments(离散化+线段树+扫描线算法)

    题目链接: D. Vika and Segments time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  3. R语言使用ggpubr包的ggdotplot函数可视化水平棒棒糖图(自定义分组数据点色彩、自定义调色板、在两端添加点图的线段segments、整体排序从大到小、自定义数据点的大小、添加数值标签)

    R语言使用ggpubr包的ggdotplot函数可视化水平棒棒糖图(自定义分组数据点色彩.自定义调色板.在两端添加点图的线段segments.整体排序从大到小.自定义数据点的大小.添加数值标签) 目录

  4. Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树扫描线

    D. Vika and Segments 题目连接: http://www.codeforces.com/contest/610/problem/D Description Vika has an i ...

  5. 关于Uri.Segments 属性的理解

    public string[] Segments { get; } Segments 属性返回一个字符串数组,该数组包含构成 URI 的绝对路径的"段"(子字符串).通过分析绝对路 ...

  6. lucene正向索引——正向信息,Index – Segments (segments.gen, segments_N) – Field(fnm, fdx, fdt) – Term (tvx, ...

    转自:http://www.cnblogs.com/forfuture1978/archive/2009/12/14/1623599.html 上面曾经交代过,Lucene保存了从Index到Segm ...

  7. PAT甲级1104 Sum of Number Segments:[C++题解]数段之和,测试点2爆double,请用long double!!!

    文章目录 题目分析 题目链接 题目分析 来源:acwing 分析:本题题意比较简单,但是不能仅仅根据定义来算. 本题思路:统计每个数在多少个区间出现过,也就是这个数需要加多少次.共有n个数,其中第i个 ...

  8. poj 1436 zoj 1391 Horizontally Visible Segments (Segment Tree)

    ZOJ :: Problems :: Show Problem 1436 -- Horizontally Visible Segments 用线段树记录表面能被看见的线段的编号,然后覆盖的时候同时把能 ...

  9. 翻译: Oralce官方文档-- Data Blocks, Extents, and Segments

    Data Blocks, Extents, and Segments                                                                   ...

  10. oracle 12c undo,Oracle 12C新特性-临时UNDO段(Temporary Undo Segments) | 信春哥,系统稳,闭眼上线不回滚!...

    在12C版本,为了减少UNDO表空间的使用率及减少REDO和归档日志的产生量,ORACLE推出了临时UNDO段(Temporary Undo Segments)新特性.这个新特性把临时表产生的UNDO ...

最新文章

  1. ttf,woff2字体转化为png图片,python读取图片
  2. python【力扣LeetCode算法题库】151- 翻转字符串里的单词
  3. ios markdown 解析_Shortcuts 教程:正则表达式修改 Markdown 链接
  4. 3143 二叉树的序遍历
  5. 【转】开发人员一定要加入收藏夹的网站
  6. struct和class之间问题(+引发的个人思考,和对共用体思考)
  7. eoLinker-API_Shop_验证码识别与生成类API调用的代码示例合集:六位图片验证码生成、四位图片验证码生成、简单验证码识别等...
  8. c# 调用java webservice 参数获取不到_用C#.NET调用Java开发的WebService传递int,double问题,出现java无法获得值!...
  9. 单片机如何产生PWM信号
  10. centos普通用户修改文件权限_centos6.5下修改文件夹权限和用户名用户组
  11. IDEA 打包 jar 包记录
  12. B站狂神Docker学习笔记
  13. 22年全国数学建模比赛ABC题思路模型
  14. MATLAB算法实战应用案例精讲-【智能优化算法】黑寡妇算法-BWO(附matlab代码)
  15. 0x00007FFE9071C408 (ucrtbase.dll) (xxx.exe 中)处有未经处理的异常: 将一个无效参数传递给了将无效参数视为严重错误的函数。
  16. ios8 系统定位问题
  17. 宝塔部署uniapp和php后端的经历
  18. 一不小心就四个月的实习总结。。。
  19. 弱网测试:使用netem模拟网络延迟、丢包、损坏、重复、和乱序等网络问题
  20. 【游戏开发实战】Unity老工程师开始搞Laya了,不想看官方文档,那就看我的教程吧(Laya2.12.0版本 | 案例 | 入门 | 教程)

热门文章

  1. 2021年中国液态金属行业现状分析:化学特性和广泛的技术应用,市场需求大[图]
  2. 卫计委:“单独二孩”政策各地明年初开始实施
  3. 2013年11月18日 二胎政策松动未来或加剧贫富分化
  4. C语言编译器哪个好_6款好用的C语言编译器推荐
  5. RubyMine安装gitee插件
  6. 微信小程序中打开其他小程序
  7. 在 JavaScript 中三个点‘...‘的意思
  8. 链脲佐菌素(STZ)诱导的啮齿动物阿尔茨海默氏病模型
  9. zotero联合坚果云与zotfile的换机同步实录
  10. 【C语言】库函数的使用与模拟实现(strlen、strcpy、strcmp....