文件名称:Lexicographic_order
- 所属分类:
- 微处理器(ARM/PowerPC等)
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 219kb
- 下载次数:
- 0次
- 提 供 者:
- 张*
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
acm算法设计:排列的字典序问题
描述:
n个元素{1,2,..., n }有n!个不同的排列。将这n!个排列按字典序排列,并编号为0,1,…,n!-1。每个排列的编号为其字典序值。例如,当n=3时,6 个不同排列的字典序值如下:
字典序值:0 1 2 3 4 5
排列:123 132 213 231 312 321
任务:给定n 以及n 个元素{1,2,..., n }的一个排列,计算出这个排列的字典序值,以及按字典序排列的下一个排列。
输入:
第1 行是元素个数n(n < 15)。接下来的1 行是n个元素{1,2,..., n }的一个排列。
输出:
第一行是字典序值,第2行是按字典序排列的下一个排列。
例输入:
8
2 6 4 5 8 1 7 3
例输出:
8227
2 6 4 5 8 3 1 7-acm algorithm design: the problem with the dictionary sequence
Descr iption:
n elements (1,2 ,..., n) there are n! different order. This n! Were arranged according to lexicographic order, and numbered 0,1, ..., n!-1. With the number of each sequence value for the dictionary. For example, when n = 3, the six different sequence with the value of the dictionary is as follows:
Lexicographic values: 0 1 2 3 4 5
Order: 123 132 213 231 312 321
Tasks: to set n and n elements (1,2 ,..., n) an arranged order to calculate the value of the dictionary sequence and arranged according to lexicographic order of the next.
Input:
Line 1 is the number of elements n (n <15). Line 1 is the next n elements (1,2 ,..., n) an order.
Output:
The first line is the value of the dictionary sequence, line 2 is arranged according to lexicographic order of the next.
Cases of type:
8
2 6 4 5 8 1 7 3
Cases the output:
8227
2 6 4 5 8 3 1 7
描述:
n个元素{1,2,..., n }有n!个不同的排列。将这n!个排列按字典序排列,并编号为0,1,…,n!-1。每个排列的编号为其字典序值。例如,当n=3时,6 个不同排列的字典序值如下:
字典序值:0 1 2 3 4 5
排列:123 132 213 231 312 321
任务:给定n 以及n 个元素{1,2,..., n }的一个排列,计算出这个排列的字典序值,以及按字典序排列的下一个排列。
输入:
第1 行是元素个数n(n < 15)。接下来的1 行是n个元素{1,2,..., n }的一个排列。
输出:
第一行是字典序值,第2行是按字典序排列的下一个排列。
例输入:
8
2 6 4 5 8 1 7 3
例输出:
8227
2 6 4 5 8 3 1 7-acm algorithm design: the problem with the dictionary sequence
Descr iption:
n elements (1,2 ,..., n) there are n! different order. This n! Were arranged according to lexicographic order, and numbered 0,1, ..., n!-1. With the number of each sequence value for the dictionary. For example, when n = 3, the six different sequence with the value of the dictionary is as follows:
Lexicographic values: 0 1 2 3 4 5
Order: 123 132 213 231 312 321
Tasks: to set n and n elements (1,2 ,..., n) an arranged order to calculate the value of the dictionary sequence and arranged according to lexicographic order of the next.
Input:
Line 1 is the number of elements n (n <15). Line 1 is the next n elements (1,2 ,..., n) an order.
Output:
The first line is the value of the dictionary sequence, line 2 is arranged according to lexicographic order of the next.
Cases of type:
8
2 6 4 5 8 1 7 3
Cases the output:
8227
2 6 4 5 8 3 1 7
(系统自动生成,下载前可以参看下载内容)
下载文件列表
排列的字典序问题
................\Debug
................\.....\StdAfx.obj
................\.....\vc60.idb
................\.....\vc60.pdb
................\.....\排列的字典序问题.exe
................\.....\排列的字典序问题.ilk
................\.....\排列的字典序问题.obj
................\.....\排列的字典序问题.pch
................\.....\排列的字典序问题.pdb
................\ReadMe.txt
................\StdAfx.cpp
................\StdAfx.h
................\排列的字典序问题.cpp
................\排列的字典序问题.dsp
................\排列的字典序问题.dsw
................\排列的字典序问题.ncb
................\排列的字典序问题.opt
................\排列的字典序问题.plg
................\Debug
................\.....\StdAfx.obj
................\.....\vc60.idb
................\.....\vc60.pdb
................\.....\排列的字典序问题.exe
................\.....\排列的字典序问题.ilk
................\.....\排列的字典序问题.obj
................\.....\排列的字典序问题.pch
................\.....\排列的字典序问题.pdb
................\ReadMe.txt
................\StdAfx.cpp
................\StdAfx.h
................\排列的字典序问题.cpp
................\排列的字典序问题.dsp
................\排列的字典序问题.dsw
................\排列的字典序问题.ncb
................\排列的字典序问题.opt
................\排列的字典序问题.plg