从1到n这n个数中任取若干个数,不能取相邻的数,并且至少取1个,要求n=12时共有多少种不同的取法

 我来答
帐号已注销
2022-07-16 · TA获得超过3116个赞
知道大有可为答主
回答量:4114
采纳率:0%
帮助的人:275万
展开全部

有数学方法。最少可以取1个数,最多可取(n+1)/2个(断尾取整)。

以n=12为例,可以取1到6个数。先计算12选6的方案数,12!/6!/(12-6)! = 924种。再分别算每种取数时有相邻数的方案数,加以扣除。例如,取3个数时,有2数相邻和3数相邻。3数相邻有10种方案;2数相邻有11种方案。但是,到了取数更大时,相邻数的情形更多,分析过程繁复,容易出错。工作量近乎枚举。

因此,编程可能更加高效。计算结果,n=12时,有376种取法。

附:计算结果和fortran代码,每个括号内是一种取法

(1);(1,3);(1,3,5);(1,3,5,7);(1,3,5,7,9);(1,3,5,7,9,11);(1,3,5,7,9,12);(1,3,5,7,10);(1,3,5,7,10,12);(1,3,5,7,11);(1,3,5,7,12);(1,3,5,8);(1,3,5,8,10);(1,3,5,8,10,12);(1,3,5,8,11);(1,3,5,8,12);(1,3,5,9);(1,3,5,9,11);(1,3,5,9,12);(1,3,5,10);(1,3,5,10,12);(1,3,5,11);(1,3,5,12);(1,3,6);(1,3,6,8);(1,3,6,8,10);(1,3,6,8,10,12);(1,3,6,8,11);(1,3,6,8,12);(1,3,6,9);(1,3,6,9,11);(1,3,6,9,12);(1,3,6,10);(1,3,6,10,12);(1,3,6,11);(1,3,6,12);(1,3,7);(1,3,7,9);(1,3,7,9,11);(1,3,7,9,12);(1,3,7,10);(1,3,7,10,12);(1,3,7,11);(1,3,7,12);(1,3,8);(1,3,8,10);(1,3,8,10,12);(1,3,8,11);(1,3,8,12);(1,3,9);(1,3,9,11);(1,3,9,12);(1,3,10);(1,3,10,12);(1,3,11);(1,3,12);(1,4);(1,4,6);(1,4,6,8);(1,4,6,8,10);(1,4,6,8,10,12);(1,4,6,8,11);(1,4,6,8,12);(1,4,6,9);(1,4,6,9,11);(1,4,6,9,12);(1,4,6,10);(1,4,6,10,12);(1,4,6,11);(1,4,6,12);(1,4,7);(1,4,7,9);(1,4,7,9,11);(1,4,7,9,12);(1,4,7,10);(1,4,7,10,12);(1,4,7,11);(1,4,7,12);(1,4,8);(1,4,8,10);(1,4,8,10,12);(1,4,8,11);(1,4,8,12);(1,4,9);(1,4,9,11);(1,4,9,12);(1,4,10);(1,4,10,12);(1,4,11);(1,4,12);(1,5);(1,5,7);(1,5,7,9);(1,5,7,9,11);(1,5,7,9,12);(1,5,7,10);(1,5,7,10,12);(1,5,7,11);(1,5,7,12);(1,5,8);(1,5,8,10);(1,5,8,10,12);(1,5,8,11);(1,5,8,12);(1,5,9);(1,5,9,11);(1,5,9,12);(1,5,10);(1,5,10,12);(1,5,11);(1,5,12);(1,6);(1,6,8);(1,6,8,10);(1,6,8,10,12);(1,6,8,11);(1,6,8,12);(1,6,9);(1,6,9,11);(1,6,9,12);(1,6,10);(1,6,10,12);(1,6,11);(1,6,12);(1,7);(1,7,9);(1,7,9,11);(1,7,9,12);(1,7,10);(1,7,10,12);(1,7,11);(1,7,12);(1,8);(1,8,10);(1,8,10,12);(1,8,11);(1,8,12);(1,9);(1,9,11);(1,9,12);(1,10);(1,10,12);(1,11);(1,12);(2);(2,4);(2,4,6);(2,4,6,8);(2,4,6,8,10);(2,4,6,8,10,12);(2,4,6,8,11);(2,4,6,8,12);(2,4,6,9);(2,4,6,9,11);(2,4,6,9,12);(2,4,6,10);(2,4,6,10,12);(2,4,6,11);(2,4,6,12);(2,4,7);(2,4,7,9);(2,4,7,9,11);(2,4,7,9,12);(2,4,7,10);(2,4,7,10,12);(2,4,7,11);(2,4,7,12);(2,4,8);(2,4,8,10);(2,4,8,10,12);(2,4,8,11);(2,4,8,12);(2,4,9);(2,4,9,11);(2,4,9,12);(2,4,10);(2,4,10,12);(2,4,11);(2,4,12);(2,5);(2,5,7);(2,5,7,9);(2,5,7,9,11);(2,5,7,9,12);(2,5,7,10);(2,5,7,10,12);(2,5,7,11);(2,5,7,12);(2,5,8);(2,5,8,10);(2,5,8,10,12);(2,5,8,11);(2,5,8,12);(2,5,9);(2,5,9,11);(2,5,9,12);(2,5,10);(2,5,10,12);(2,5,11);(2,5,12);(2,6);(2,6,8);(2,6,8,10);(2,6,8,10,12);(2,6,8,11);(2,6,8,12);(2,6,9);(2,6,9,11);(2,6,9,12);(2,6,10);(2,6,10,12);(2,6,11);(2,6,12);(2,7);(2,7,9);(2,7,9,11);(2,7,9,12);(2,7,10);(2,7,10,12);(2,7,11);(2,7,12);(2,8);(2,8,10);(2,8,10,12);(2,8,11);(2,8,12);(2,9);(2,9,11);(2,9,12);(2,10);(2,10,12);(2,11);(2,12);(3);(3,5);(3,5,7);(3,5,7,9);(3,5,7,9,11);(3,5,7,9,12);(3,5,7,10);(3,5,7,10,12);(3,5,7,11);(3,5,7,12);(3,5,8);(3,5,8,10);(3,5,8,10,12);(3,5,8,11);(3,5,8,12);(3,5,9);(3,5,9,11);(3,5,9,12);(3,5,10);(3,5,10,12);(3,5,11);(3,5,12);(3,6);(3,6,8);(3,6,8,10);(3,6,8,10,12);(3,6,8,11);(3,6,8,12);(3,6,9);(3,6,9,11);(3,6,9,12);(3,6,10);(3,6,10,12);(3,6,11);(3,6,12);(3,7);(3,7,9);(3,7,9,11);(3,7,9,12);(3,7,10);(3,7,10,12);(3,7,11);(3,7,12);(3,8);(3,8,10);(3,8,10,12);(3,8,11);(3,8,12);(3,9);(3,9,11);(3,9,12);(3,10);(3,10,12);(3,11);(3,12);(4);(4,6);(4,6,8);(4,6,8,10);(4,6,8,10,12);(4,6,8,11);(4,6,8,12);(4,6,9);(4,6,9,11);(4,6,9,12);(4,6,10);(4,6,10,12);(4,6,11);(4,6,12);(4,7);(4,7,9);(4,7,9,11);(4,7,9,12);(4,7,10);(4,7,10,12);(4,7,11);(4,7,12);(4,8);(4,8,10);(4,8,10,12);(4,8,11);(4,8,12);(4,9);(4,9,11);(4,9,12);(4,10);(4,10,12);(4,11);(4,12);(5);(5,7);(5,7,9);(5,7,9,11);(5,7,9,12);(5,7,10);(5,7,10,12);(5,7,11);(5,7,12);(5,8);(5,8,10);(5,8,10,12);(5,8,11);(5,8,12);(5,9);(5,9,11);(5,9,12);(5,10);(5,10,12);(5,11);(5,12);(6);(6,8);(6,8,10);(6,8,10,12);(6,8,11);(6,8,12);(6,9);(6,9,11);(6,9,12);(6,10);(6,10,12);(6,11);(6,12);(7);(7,9);(7,9,11);(7,9,12);(7,10);(7,10,12);(7,11);(7,12);(8);(8,10);(8,10,12);(8,11);(8,12);(9);(9,11);(9,12);(10);(10,12);(11);(12)

total = 376

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式