1,2,3,4,5,6 任意组合相乘,求最大数
with
a
as
(
select to_char(rownum) num1
from dual
connect by rownum<=6
),
b(num1 ,num2,num3 )
as
(
select a.num1 num1,a.num1 num2,1 num3
from a
union all
select a.num1 num1,b.num2||'*'||a.num1 num2,b.num3+1
from a,b
where instr(b.num2,a.num1)=0
and b.num1>a.num1
)
select b1.num2,b2.num2,dbms_aw.eval_number(replace(b1.num2,'*','')||'*'||replace(b2.num2,'*',''))
From b b1,b b2
where b1.num3+b2.num3=6
and substr(b1.num2,1,1)>substr(b2.num2,1,1)
and dbms_aw.eval_number(replace(b1.num2||'*'||b2.num2,'*','+'))=21
and dbms_aw.eval_number(b1.num2||'*'||b2.num2)=1*2*3*4*5*6
比较笨的方法给算出来了,是631 * 542最大
631 542 342002
632 541 341912
63 5421 341523
6321 54 341334
641 532 341012
642 531 340902
64 5321 340544
6421 53 340313
621 543 337203
62 5431 336722
643 521 335003
。
。
。
。
。
。
。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25323853/viewspace-692623/ ,如需转载,请注明出处,否则将追究法律责任。