2 人解决,10 人已尝试。
3 份提交通过,共有 44 份提交。
9.7 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
Given a string of characters, we can permute the individual characters to make new strings. If we can impose an ordering on the characters (say alphabetic sequence), then the strings themselves can be ordered and any given permutation can be given a unique number designating its position in that ordering. For example the string `acab’ gives rise to the following 12 distinct permutations:
Thus the string `acab’ can be characterised in this sequence as 5.
Write a program that will read in a string and determine its position in the ordered sequence of permutations of its constituent characters. Note that numbers of permutations can get very large; however we guarantee that no string will be given whose position is more than 2^31-1=2,147,483,647 .
Input will consist of a series of lines, each line containing one string. Each string will consist of up to 30 lower case letters, not necessarily distinct. The file will be terminated by a line consisting of a single #.
Output will consist of a series of lines, one for each line of the input. Each line will consist of the position of the string in its sequence, right justified in a field of width 10.
Input will consist of a series of lines, each line containing one string. Each string will consist of up to 30 lower case letters, not necessarily distinct. The file will be terminated by a line consisting of a single #.
Output will consist of a series of lines, one for each line of the input. Each line will consist of the position of the string in its sequence, right justified in a field of width 10.
2 人解决,10 人已尝试。
3 份提交通过,共有 44 份提交。
9.7 EMB 奖励。