这是 PUZZLEUP 2014 的15题 ,ITPUB的oracle开发版有一专门的帖子
There are 24 players in a chess tournament. 8 teams participated with 2 players , and 8 teams participated with 1 player. For the 12 matches in the first round, the pairings will be drawn randomly. What is the probability that at least 4 matches will be played between players from the same school?
Enter your answer as a simplified fraction. Example:12/23
棋手
共有24名选手参加国际象棋比赛。 8支队有2名选手参加,8支队以1名选手参加。 在第一轮的12场比赛,选手之间是随机配对的。
至少有四场比赛是在同一个学校的选手之间进行,这样的概率是多少?
将你的答案输入为简化分数,例如:12/23
--------------------------------------------
自我感觉概率统计学的还行,结果弄了半天还是没有推出公式, 最后,写了个穷举法sql来算
结果,运行一小时还没有出结果:(
运行到14人就要40来秒了, 有兴趣的,可以推推出公式玩玩
There are 24 players in a chess tournament. 8 teams participated with 2 players , and 8 teams participated with 1 player. For the 12 matches in the first round, the pairings will be drawn randomly. What is the probability that at least 4 matches will be played between players from the same school?
Enter your answer as a simplified fraction. Example:12/23
棋手
共有24名选手参加国际象棋比赛。 8支队有2名选手参加,8支队以1名选手参加。 在第一轮的12场比赛,选手之间是随机配对的。
至少有四场比赛是在同一个学校的选手之间进行,这样的概率是多少?
将你的答案输入为简化分数,例如:12/23
--------------------------------------------
自我感觉概率统计学的还行,结果弄了半天还是没有推出公式, 最后,写了个穷举法sql来算
-
--24个人
-
with a as (select power(2, rownum-1) rn, rownum rnc from dual connect by rownum <=24)
-
, b as (select rownum rn, a.rn+b.rn txx ,
-
--flag为1是同一队
-
case when b.rnc=a.rnc+1 and b.rnc<=16 and mod(b.rnc,2)=0 then 1 else 0 end flag
-
from a, a b where b.rn>a.rn)
-
,d (idx, rn, txx,flag) as
-
( select 1 idx, b.rn, b.txx , b.flag from b
-
union all
-
select d.idx+1, b.rn , d.txx +b.txx txx ,d.flag+b.flag
-
from d,b where b.rn>d.rn and bitand(d.txx,b.txx)=0
-
)
-
--4代表至少4队
-
select sum(case when d.flag>=4 then 1 else 0 end) ff, count(1) alll
-
,sum(case when d.flag>=1 then 1 else 0 end) / count(1)
-
--12是配成12队的
- from d where d.idx=12
结果,运行一小时还没有出结果:(
运行到14人就要40来秒了, 有兴趣的,可以推推出公式玩玩
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/134308/viewspace-1334392/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/134308/viewspace-1334392/
291

被折叠的 条评论
为什么被折叠?



