Codeforces 1315A Dead Pixel (水题)

Screen resolution of Polycarp's monitor is a×ba×b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x,y)(x,y) (0x<a,0y<b0≤x<a,0≤y<b ). You can consider columns of pixels to be numbered from 00 to a1a−1 , and rows — from 00 to b1b−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 (1t1041≤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 (1a,b1041≤a,b≤104 ; 0x<a0≤x<a ; 0y<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.

Example

Input
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
Output
56
6
442
1
45
80
找出这个点左右上下四部分最大的一部分即可。
复制代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    int a,b,x,y;
    while(t--)
    {
        cin>>a>>b>>x>>y;
        int s1=a*y;
        int s2=b*x;
        int s3=a*(b-y-1);
        int s4=b*(a-x-1);
        s2=max(s1,s2);
        s4=max(s3,s4);
        cout<<max(s2,s4)<<endl;
    }
    return 0;
}
复制代码

 

posted @   脂环  阅读(414)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示
主题色彩