寒假集训.ID Codes
来源:互联网 发布:台湾综艺节目软件 编辑:程序博客网 时间:2024/09/21 09:25
Description
ID Codes
It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, the Government decides on a radical measure--all citizens are to have a tiny microcomputer surgically implanted in their left wrists. This computer will contains all sorts of personal information as well as a transmitter which will allow people's movements to be logged and monitored by a central computer. (A desirable side effect of this process is that it will shorten the dole queue for plastic surgeons.)
An essential component of each computer will be a unique identification code, consisting of up to 50 characters drawn from the 26 lower case letters. The set of characters for any given code is chosen somewhat haphazardly. The complicated way in which the code is imprinted into the chip makes it much easier for the manufacturer to produce codes which are rearrangements of other codes than to produce new codes with a different selection of letters. Thus, once a set of letters has been chosen all possible codes derivable from it are used before changing the set.
For example, suppose it is decided that a code will contain exactly 3 occurrences of `a', 2 of `b' and 1 of `c', then three of the allowable 60 codes under these conditions are:
abaabc abaacb ababac
These three codes are listed from top to bottom in alphabetic order. Among all codes generated with this set of characters, these codes appear consecutively in this order.
Write a program to assist in the issuing of these identification codes. Your program will accept a sequence of no more than 50 lower case letters (which may contain repeated characters) and print the successor code if one exists or the message `No Successor' if the given code is the last in the sequence for that set of characters.
Input and Output
Input will consist of a series of lines each containing a string representing a code. The entire file will be terminated by a line consisting of a single #.
Output will consist of one line for each code read containing the successor code or the words `No Successor'.
Sample input
abaacbcbbaa#
Sample output
ababacNo Successor
这道题可以偷懒用next_permutation函数直接求下一个排列6666666:
- 寒假集训.ID Codes
- 寒假集训
- ID Codes
- 寒假集训小记
- 寒假集训后记
- 寒假集训.Reverse Root
- 寒假集训.Rope
- 寒假集训.Discrete-Function
- 寒假集训.Intersection
- 寒假集训.Skew Binary
- 14寒假集训GeoDefense
- 寒假集训总结
- 寒假集训 1005
- 寒假集训 1007
- 寒假集训重要内容总结
- 寒假集训日常!
- 2016 寒假集训有感
- 寒假集训 day6
- [leetcode]136 Single Number
- Java 枚举7常见种用法 很好的文章
- 自定义控件其实很简单2/3
- Firebug控制台详解
- android:installLocation
- 寒假集训.ID Codes
- Android 百度地图 SDK v3.0.0 (三) 添加覆盖物Marker与InfoWindow的使用
- 自定义控件其实很简单2/3
- 第一章 maven创建Android项目
- 最速梯度法和牛顿法的步长的算法
- 面试准备
- android Context 基本概念
- 添加悬浮,判断手机系统的工具类
- 在sun官网上下载的tutorial找不到image和文件的解决办法