/*
* POJ_1146.cpp
*
* Created on: 2013年10月8日
* Author: Administrator
*/ #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> using namespace std; char s[60];
int l; bool get(){
int i = l - 1;
int j; while(i > 0 && s[i-1] >= s[i]){
i--;
}
if(!i){
return false;
} int mp = i;
for(j = i + 1 ; j < l ; ++j){
if(s[i-1] >= s[j]){
continue;
} if(s[j] < s[mp]){
mp = j;
}
} swap(s[mp],s[i-1]);
sort(s+i,s+l);
return 1;
} int main(){
while(scanf("%s",&s)!=EOF,s[0] !='#'){
l = strlen(s);
if(get()){
printf("%s\n",s);
}else{
printf("No Successor\n");
}
}
}

(组合数学3.1.1.1)POJ 1146 ID Codes(字典序法)的更多相关文章

  1. poj 1146 ID Codes (字符串处理 生成排列组合 生成当前串的下一个字典序排列 【*模板】 )

    ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6229   Accepted: 3737 Descript ...

  2. POJ 1146 ID Codes 用字典序思想生成下一个排列组合

    ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7644   Accepted: 4509 Descript ...

  3. POJ 1146 ID Codes (UVA146)

    // 求下一个排列// 如果已经是最后一个排列// 就输出 No Successor// stl 或 自己写个 生成排列 我测试了下 两个速率是一样的.只是代码长度不同 /* #include < ...

  4. ACM POJ 1146 ID Codes

    题目大意:输入一个字符串.输出它的下一个字典序排列. 字典序算法思想: 1.从右向左寻找字符串找出第一个a[i]<a[i+1]的位置i; 2.从右向左找出第一个大于a[i]的元素a[j]; 3. ...

  5. 【水一发next_permutation】poj 1146——ID Codesm

    来源:点击打开链接 求字典序下一位,没有直接输出没有.全排列函数秒水过. #include <iostream> #include <algorithm> #include & ...

  6. 1146 ID Codes

    题目链接: http://poj.org/problem?id=1146 题意: 给定一个字符串(长度不超过50), 求这个字符串的下一个字典序的字符串, 如果已经是最大字典序, 那么输出 " ...

  7. POJ 1146:ID Codes

    ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6281 Accepted: 3769 Description ...

  8. uva146 ID codes

    Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In or ...

  9. Brute Force & STL --- UVA 146 ID Codes

     ID Codes  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&a ...

随机推荐

  1. iOS中常用的第三方

    1. ZBarSDK 二维码.条形码 http://www.cnblogs.com/qingche/p/4242129.html

  2. mahout分类

    分类看起来比聚类和推荐麻烦多了 分类算法与聚类和推荐算法的不同:必须是有明确结果的,必须是有监督的,主要用于预测和检测 Mahout的优势 mahout的分类算法对资源的要求不会快于训练数据和测试数据 ...

  3. Java面向对象程序设计--接口和内部类

    1.接口的定义: In the Java programming language, an interface is not a class but          staff[0] =       ...

  4. chrome输入框记住密码导致背景黄色的解决方案

    在form头部增加以下内容 <input type="text" style="display:hidden;"> <input type=& ...

  5. Java学习----finally块

    public class Test { String x; public static void main(String[] args) { Test test = new Test(); try { ...

  6. time返回当前的 Unix 时间戳而$_SERVER["REQUEST_TIME"]得到请求开始时的时间戳

    time():返回当前的 Unix 时间戳 $_SERVER["REQUEST_TIME"]:得到请求开始时的时间戳,可以用来判断完成整个php处理的时间

  7. X-window

    X-Window(也常称为X11或X)系统是一种以位图方式显示的软件视窗系统,最初是1984年麻省理工学院的研究,之后变成UNIX.类UNIX. 以及OpenVMS等操作系统所一致适用的标准化软件工具 ...

  8. 构建微服务:Spring boot

    构建微服务:Spring boot 在上篇文章构建微服务:Spring boot 提高篇中简单介绍了一下spring data jpa的基础性使用,这篇文章将更加全面的介绍spring data jp ...

  9. EFBaseDal新增删除方法

    public T Delete(int id )        {            var entity = db.Set<T>().Find(id);            T t ...

  10. C语言之 短路原则

    a=0;b=1 c=a&&(b=3) 最终c=0; b=1 因为从左至右进行时,若遇到运算符左边的操作数是 0(逻辑假),则停止运算. a=1;b=1;c=0; d=a||b||(c= ...