|
|
为了方便所有看贴的人,我再细致的说明一下,掩码的计算:
--c.bit*(power(2,(r.a-1)*6)+power(2,(r.b-1)*6)+power(2,(r.c-1)*6))
--关于这个的理解
--掩码生成公式
假设删除的行号是 (1,4,6),删除的列号是 (2,3,5)
那么实际上,留下的9个点的坐标是
(2,1),(2,4),(2,6)
(3,1),(3,4),(3,6)
(5,1),(5,4),(5,6)
换句话,即是留下的是 (2,3,5)行的 <1,4,6>向量,而 <1,4,6>向量的 6位二进制码是 100**,
因此,36 位的掩码应该是
000000
100**
100**
000000
100**
000000
而这个36位的二进制的值应该是 (100**)*( 2^((2-1)*6) + 2^((3-1)*6) + 2^((5-1)*6) )
这个就是计算公式 X*( 2^((a-1)*6) + 2^((b-1)*6) + 2^((c-1)*6)
SQL> with t(n,c,x,y) as (select level,power(2,level-1),ceil(level/6),mod(level-1,6)+1 from dual connect by level<=6*6),
2 b3(a,b,c,bit) as (select a.n,b.n,c.n,a.c+b.c+c.c from t a,t b,t c where a.n<b.n and b.n<c.n and c.n<=6),
3 b9(b)as(select r.bit*(power(2,(c.a-1)*6)+power(2,(c.b-1)*6)+power(2,(c.c-1)*6)) from b3 r,b3 c),
4 s(lvl,n,csum,nlist,px,py) as ( select 1,n,c,cast(n as varchar2(100)),power(10,t.x),power(10,t.y)
5 from t
6 where t.n <=6
7 union all
8 select lvl + 1,b.n,s.csum + b.c,s.nlist||','||b.n,px+power(10,b.x),py+power(10,b.y)
9 from s,t b
10 where s.n < b.n and b.x < floor(s.n/6) +3
11 and instr(px+power(10,b.x),3)=0 and instr(py+power(10,b.y),3)=0
12 and lvl < 10
13 and b.n between floor(lvl/2)*6+1 and floor(lvl/2)*6+6*2 )
14 select count(nlist)
15 from s
16 where lvl = 10 and not exists(select 1 from b9 where bitand(csum, b9.b) =0)
17 /
COUNT(NLIST)
------------
32400
Executed in 355.719 seconds
|
|