```with x as(select level x from dual connect by level<=4),
y as(select level y from dual connect by level<=3)
select (x2.x-x1.x)width,(y2.y-y1.y)hight,count(*)
from x x1,x x2,y y1,y y2
where x2.x>x1.x and y2.y>y1.y
group by (x2.x-x1.x),(y2.y-y1.y)
order by 1,2;

WIDTH      HIGHT   COUNT(*)
----- ---------- ----------
1          1          6
1          2          3
2          1          4
2          2          2
3          1          2
3          2          1
```

```1x1 : (4-1)(3-1) =6
1x2 : (4-1)(3-2) =3

2x1 : (4-2)(3-1) =4
2x2 : (4-2)(3-2) =2

3x1 : (4-3)(3-1) =2
3x2 : (4-3)(3-2) =1

=(4-1)(3*2-sum(1->2))
+(4-2)(3*2-sum(1->2))
+(4-3)(3*2-sum(1->2))

=(4*3-sum(1->3))(3*2-sum(1->2))
=(12-6)*(6-3)
=18
```

```对于m*n的长方形，和为
(m*(m-1)-(1+m-1)*(m-1)/2))
*(n*(n-1)-(1+n-1)*(n-1)/2))
=m(m-1)n(n-1)/4
```

```和=m(m+1)n(n+1)/4

```

m>=方程`m*m+m-2sqrt(2000000)=0`的较大的根 `1/2(-1+sqrt((1+4*2000sqrt(2))`

```SQL> select 1/2*(-1+sqrt(1+4*2000*sqrt(2)))a from dual;

A
----------
52.6853093
```

```with m as(select level+52 m from dual connect by level<=100),
n as(select level n from dual connect by level<=53)
select min(m*(m+1)*n*(n+1)/4-2e6) a from m,n where abs(m*(m+1)*n*(n+1)/4-2e6)<=1000;

A
------
-2

with m as(select level+52 m from dual connect by level<=100),
n as(select level n from dual connect by level<=53),
min_diff as(select min(m*(m+1)*n*(n+1)/4-2e6) a from m,n where abs(m*(m+1)*n*(n+1)/4-2e6)<=1000)
select m,n,m*n from m,n where m*(m+1)*n*(n+1)/4-2e6=(select a from min_diff);

M          N        M*N
------ ---------- ----------
77         36       2772
```

1. 不知道怎么证明-2是最接近的。要不就从1、-1开始测试。
2. m的上限怎么确定，这里100是碰巧，如果写成10就不能得到解