|
帮你改下取模的判断:
with t as (select level n from dual connect by level < 50),
s(lvl,n_list,n_sum,n_mul,n_last) as (select 1,
cast(n as varchar2(100)),
n,
n,
n
from t
union all
select s.lvl + 1,
s.n_list||','||t.n,
s.n_sum + t.n,
s.n_mul*t.n,
t.n
from s,t
where s.n_sum + t.n <= 50
and s.n_last < t.n
and not exists
(select null
from dual
where mod(t.n,regexp_substr(s.n_list,'[^,]+',1,level)) = 0
connect by level <= regexp_count(s.n_list,',',1) + 1
)
)
SELECT max(n_mul),max(n_list) keep(dense_rank first ORDER BY n_mul DESC) FROM s where n_sum = 50;
等M哥对下答案。 |
|