您可以通过多少种方式排列'n'(1至n)个数字的序列,使索引中没有数字出现在其值中?'n'号码序列的排列
对于如
1 can not be at first position
2 can not be at second position
.
.
n can not be at nth position
请给一个通用的解决方案。也解决它n = 6。 它不是功课。
您可以通过多少种方式排列'n'(1至n)个数字的序列,使索引中没有数字出现在其值中?'n'号码序列的排列
对于如
1 can not be at first position
2 can not be at second position
.
.
n can not be at nth position
请给一个通用的解决方案。也解决它n = 6。 它不是功课。
设P(n)为n
这样的编号的数字。
For 123456....n
Cases are of the form
2*****
3*****
4*****
5*****
.
.
n*****
Now 1 can be anywhere at the rest (n-1) positions.
If 1 is put at the position of the number replacing it...
21****
3*1***
4**1**
.
.
n****1
then first and the replaced numbers are fixed.
Then total cases = (n-1) * P(n-2)
Else if
1 is also restricted not to be at a particular position (positions in above cases)
Then total cases = (n-1) * P(n-1)
所以
P(N)=(P(N-1)+ P(N-2))*(N-1)
与P(1)= 0
和P(2)= 1
只为知识共享 – Shashwat 2012-07-18 05:44:04
你想要定点自由排列,也被称为derangements。他们的数字公式比可能有固定点的排列数稍微复杂一些。
非常轻微,与n!/ e最接近的整数。维基百科的文章没有清楚地解释这一点,尽管它注意到一些紊乱收敛于1/e并且给出了“floor((n!/ e)+(1/2))”的精确表达式。 – hardmath 2012-07-18 14:31:13
紊乱的(固定点自由排列)的n
事物的数目是round(n!/e)
其中e
是自然对数的底。这里的round
表示最接近的整数函数。这在the Wikipedia article中有描述,但方式可以明确。
对于n = 6
一个容易计算有round(264.87...) = 265
排列紊乱。
如果它像鸭子一样走路,并像鸭子一样说话......你确定*它不是作业吗? – 2012-07-18 05:16:48
如何以编程方式生成错乱的问题已经[在此处处理](http://stackoverflow.com/q/8369941/487781)。计算它们的公式严格来说是一个数学主题(并在MathSE上查看我的答案,链接到这样一个问题)。 – hardmath 2012-07-18 14:42:32