|
本帖最后由 〇〇 于 2018-11-15 14:42 编辑
n = 10 也又值,但面积不是最小
SQL>
SQL> with t as
2 (select sys_connect_by_path(n,',') nlist
3 from (select level n from dual connect by level<=10)
4 where level = 10
5 connect by nocycle prior n <> n),
6 s as (
7 select regexp_substr(nlist,'[^,]+',1,1) x1,
8 regexp_substr(nlist,'[^,]+',1,2) y1,
9 regexp_substr(nlist,'[^,]+',1,3) x2,
10 regexp_substr(nlist,'[^,]+',1,4) y2,
11 regexp_substr(nlist,'[^,]+',1,5) x3,
12 regexp_substr(nlist,'[^,]+',1,6) y3,
13 regexp_substr(nlist,'[^,]+',1,7) x4,
14 regexp_substr(nlist,'[^,]+',1,8) y4,
15 regexp_substr(nlist,'[^,]+',1,9) x5,
16 regexp_substr(nlist,'[^,]+',1,10) y5
17 from t),
18 r as (
19 select x1,y1,
20 x2,y2,
21 x3,y3,
22 x4,y4,
23 x5,y5
24 from s
25 where x1 = x4 + x5
26 and x3 = x2 + x5
27 and y2 = y1 + y5
28 and y4 = y3 + y5
29 and y1 + y4 = y2 + y3
30 and x1 + x2 = x3 + x4)
31 select x1,y1,
32 x2,y2,
33 x3,y3,
34 x4,y4,
35 x5,y5,
36 (x1+x2)||'*'||(y2+y3) as rec_area
37 from r
38 where (x1+x2)*(y2+y3) = (select min((x1+x2)*(y2+y3)) from r)
39 /
X1 Y1 X2 Y2 X3 Y3 X4 Y4 X5 Y5 REC_AREA
------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -------
6 1 5 8 9 3 2 10 4 7 11*11
6 3 5 10 9 1 2 8 4 7 11*11
8 2 3 6 10 5 1 9 7 4 11*11
8 5 3 9 10 2 1 6 7 4 11*11
9 1 2 8 6 3 5 10 4 7 11*11
9 3 2 10 6 1 5 8 4 7 11*11
10 2 1 6 8 5 3 9 7 4 11*11
10 5 1 9 8 2 3 6 7 4 11*11
帮你编辑了
8 rows selected
SQL> select 11*11 from dual;
11*11
----------
121
SQL> |
|