【发布时间】:2013-10-07 19:22:01
【问题描述】:
有多少种方法可以用 2 个固定值填充 n 个位置,并用 2 个选定值之间的值填充其余位置,这样我们就不会得到重复?
示例:n=4,固定值 1 和 3
case 1 : fix 1 on position 1 and 3 on position 2
1 3 1 1
1 3 1 2
1 3 2 1
1 3 2 2
1 3 1 3
1 3 3 1
1 3 3 3
1 3 2 3
1 3 3 2
case 2 : fix 1 on position 1 and 3 on position 3
1 1 3 1
1 1 3 2
1 2 3 1
1 2 3 2
1 3 3 2
1 2 3 3
1 3 3 1
1 1 3 3
1 3 3 3
now in case 1 and 2 : 1 3 3 3 and 1 3 3 1 and 1 3 3 2 are repeating
case 3 : ....similarly other cases follow
到目前为止我所做的是:nC2 * POWER( (max-min+1) , n-2 ) - duplicates,但无法减去重复项。
【问题讨论】:
-
能否请说明您正在考虑多少个案例以及它们是如何定义的?也许您必须考虑 2 个固定值在任何 2 个位置的所有可能定位? ..或者要使用的案例和职位的数量作为单独的数据给出?
标签: algorithm combinations permutation