--第一题
用1、2、3、4、5组成一个6位数,使相邻的两位之间间隔1,问:这样的组合有多少种?
with t as
(select level x from dual connect by level < 6)
select a.x|| b.x|| c.x||d.x|| e.x
from t a, t b, t c, t d, t e, t f
where abs(a.x - b.x) = 1
and abs(b.x - c.x) = 1
and abs(c.x - d.x) = 1
and abs(d.x - f.x) = 1
and abs(f.x - e.x) = 1
;
--第二题
有一筐鸡蛋,如果一个一个拿全拿完、两个两个拿剩一个、三个三个拿全拿完、四个四个拿剩1个、
五个五个拿剩4个、六个六个拿剩3个、七个七个拿全拿完、八个八个拿剩1个、九个九个拿全拿完,
问:这筐鸡蛋至少多少个?
with t1 as (select (level-1) x from dual connect by level<=10000)
select t1.X
from t1
where mod(t1.X,2) = 1
and mod(t1.X,3) = 0
and mod(t1.X,4) = 1
and mod(t1.X,5) = 4
and mod(t1.X,6) = 3
and mod(t1.X,7) = 0
and mod(t1.X,8) = 1
and mod(t1.X,9) = 0
;