Questions tagged «permutations»

排列是某些对象列表的特定顺序。用置换标记的问题通常涉及查找或生成置换,包括文本的字谜。

6
排列编号
挑战 对于给定的n个整数集,编写一个程序,该程序将输出其字典索引。 规则 输入只能是由空格分隔的一组唯一的非负整数。 您应该输出排列的字典索引(范围从0到n!-1)。 不能使用置换库或内置置换。 您可能不会生成输入的排列集或排列的任何子集来帮助您找到索引。 您也不能将给定的排列递增或递减到下一个/上一个(按字典顺序)排列。 如果您找到某种无需使用阶乘就可以完成的奖励积分(-10字节)。 对于n = 100,运行时间应少于1分钟 字节数最短的代码获胜 优胜者选择星期二(2014年7月22日) 有关排列的更多信息 http://www.monkeyphysics.com/articles/read/26/numbering_permutations.html 排列组运算 http://lin-ear-th-inking.blogspot.com/2012/11/enumerating-permutations-using.html 例子 0 1 2 --> 0 0 2 1 --> 1 1 0 2 --> 2 1 2 0 --> 3 2 0 1 --> 4 2 1 0 --> 5 0 …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.