码迷,mamicode.com
首页 > 其他好文 > 详细

10位同学依次登上一辆大巴

时间:2018-03-06 14:35:52      阅读:1954      评论:0      收藏:0      [点我收藏+]

标签:union   class   body   union all   count   sel   依次   nio   顺序   

10位同学依次登上一辆大巴,其中5个男同学,5个女同学,要求任何时候车上男同学的人数都不少于女同学的人数,不考虑有人下车的情况,请问总共有多少种上车顺序?

WITH a AS(
SELECT ‘m1‘ NAME
,1 VALUE
FROM dual
UNION ALL
SELECT ‘m2‘ NAME
,1 VALUE
FROM dual
UNION ALL
SELECT ‘m3‘ NAME
,1 VALUE
FROM dual
UNION ALL
SELECT ‘m4‘ NAME
,1 VALUE
FROM dual
UNION ALL
SELECT ‘m5‘ NAME
,1 VALUE
FROM dual
UNION ALL
SELECT ‘fm1‘ NAME
,-1 VALUE
FROM dual
UNION ALL
SELECT ‘fm2‘ NAME
,-1 VALUE
FROM dual
UNION ALL
SELECT ‘fm3‘ NAME
,-1 VALUE
FROM dual
UNION ALL
SELECT ‘fm4‘ NAME
,-1 VALUE
FROM dual
UNION ALL
SELECT ‘fm5‘ NAME
,-1 VALUE
FROM dual
)
SELECT COUNT(*)
from a
,a a1
,a a2
,a a3
,a a4
,a a5
,a a6
,a a7
,a a8
,a a9
WHERE a.name<>a1.name
AND a.name<>a2.name AND a1.name<>a2.name
AND a.name<>a3.name AND a1.name<>a3.name AND a2.name<>a3.name
AND a.name<>a4.name AND a1.name<>a4.name AND a2.name<>a4.name AND a3.name<>a4.name
AND a.name<>a5.name AND a1.name<>a5.name AND a2.name<>a5.name AND a3.name<>a5.name AND a4.name<>a5.name
AND a.name<>a6.name AND a1.name<>a6.name AND a2.name<>a6.name AND a3.name<>a6.name AND a4.name<>a6.name AND a5.name<>a6.name
AND a.name<>a7.name AND a1.name<>a7.name AND a2.name<>a7.name AND a3.name<>a7.name AND a4.name<>a7.name AND a5.name<>a7.name AND a6.name<>a7.name
AND a.name<>a8.name AND a1.name<>a8.name AND a2.name<>a8.name AND a3.name<>a8.name AND a4.name<>a8.name AND a5.name<>a8.name AND a6.name<>a8.name AND a7.name<>a8.name
AND a.name<>a9.name AND a1.name<>a9.name AND a2.name<>a9.name AND a3.name<>a9.name AND a4.name<>a9.name AND a5.name<>a9.name AND a6.name<>a9.name AND a7.name<>a9.name AND a8.name<>a9.name
AND a.value>=0
AND a.value+a1.value>=0
AND a.value+a1.value+a2.value>=0
AND a.value+a1.value+a2.value+a3.value>=0
AND a.value+a1.value+a2.value+a3.value+a4.value>=0
AND a.value+a1.value+a2.value+a3.value+a4.value+a5.value>=0
AND a.value+a1.value+a2.value+a3.value+a4.value+a5.value+a6.value>=0
AND a.value+a1.value+a2.value+a3.value+a4.value+a5.value+a6.value+a7.value>=0
AND a.value+a1.value+a2.value+a3.value+a4.value+a5.value+a6.value+a7.value+a8.value>=0
AND a.value+a1.value+a2.value+a3.value+a4.value+a5.value+a6.value+a7.value+a8.value+a9.value>=0

604800

10位同学依次登上一辆大巴

标签:union   class   body   union all   count   sel   依次   nio   顺序   

原文地址:https://www.cnblogs.com/moqingtong/p/8513999.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!