Dead Pixel

Screen resolution of Polycarp's monitor is a \times ba×b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y)(x,y) (0 \le x < a, 0 \le y < b0≤x<a,0≤y<b). You can consider columns of pixels to be numbered from 00 to a-1a−1, and rows — from 00 to b-1b−1.

Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.

Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.

Input

In the first line you are given an integer tt (1 \le t \le 10^41≤t≤104) — the number of test cases in the test. In the next lines you are given descriptions of tt test cases.

Each test case contains a single line which consists of 44 integers a, b, xa,b,x and yy (1 \le a, b \le 10^41≤a,b≤104; 0 \le x < a0≤x<a; 0 \le y < b0≤y<b) — the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2a+b>2 (e.g. a=b=1a=b=1 is impossible).

Output

Print tt integers — the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.

Sample 1

InputcopyOutputcopy
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
56
6
442
1
45
80

Note

In the first test case, the screen resolution is 8 \times 88×8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.

 题意:

在一个axb的屏幕上有一个坏点(x,y),问不包含坏点的最大矩形面积。

思路:

比较可能四个矩形的大小。

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
void slove(){
    int t;
    cin>>t;
    while(t--)
    {
        int a,b,x,y;
        cin>>a>>b>>x>>y;
        int ans=a*y;
        ans=max(ans,b*x);
        ans=max(ans,a*(b-y-1));
        ans=max(ans,b*(a-x-1));
        cout<<ans<<endl;
    }
}
int main(){
    slove();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值