摘要:排列的字典序问题Time Limit:2000MSMemory Limit:65535KBSubmissions:1128Accepted:162Descriptionn个元素{1,2,..., n }有n!个不同的排列。将这n!个排列按字典序排列,并编号为0,1,…,n!-1。每个排列的编号为其字典序值。例如,当n=3时,6 个不同排列的字典序值如下:0 1 2 3 4 5123 132 213 231 312 321任务:给定n 以及n 个元素{1,2,..., n }的一个排列,计算出这个排列的字典序值,以及按字典序排列的下一个排列。Input第1 行是元素个数n(n < 15)。
阅读全文
摘要:OrdersTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u DescriptionThe stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are stored in the same warehouse (i.e. in the same building)
阅读全文
摘要:数字全排列Time Limit:1000MSMemory Limit:65535KBSubmissions:57Accepted:33Description从1~9之间顺序取N个数字,组成每位数不重复的所有可能的N位数,按从小到大的顺序进行编号,当输入其中的任何一个数M是,能找出该数对应的编号。如:当N = 3,M = 132时,则输出: [123(1), 132(2), 213(3), 231(4), 312(5), 321(6)]——> X = 2Input输入只有一行,两个正整数N和M(1 ≤ N ≤ 9,1 ≤ K ≤ 987654321),之间用一个空格分隔开。Output输出
阅读全文