UVA 146 ID Codes

求用这些字母的下一个排列是什么。直接使用C++ STL库里面的next_permutation

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    char s[1000];
    while (~scanf("%s", s))
    {
        if (strcmp(s, "#") == 0) break;
        int y = strlen(s), i;
        for (i = 0; i < y - 1; i++) if (s[i] < s[i + 1]) break;
        if (i == y - 1) printf("No Successor\n");
        else
        {
            next_permutation(s, s + y);
            printf("%s\n", s);
        }
    }
    return 0;
}
时间: 2024-08-07 04:33:12

UVA 146 ID Codes的相关文章

UVA - 146 - ID Codes (枚举排列)

UVA - 146 ID Codes Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its ci

Brute Force &amp; STL --- UVA 146 ID Codes

 ID Codes  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=3&problem=82&mosmsg=Submission+received+with+ID+14418598 Mean: 求出可重排列的下一个排列. analyse: 直接用STL来实现就可.自己手动写了一个,并不复杂.

UVA 146 ID Codes(下一个排列)

C - ID Codes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Appoint description:  System Crawler  (2014-05-12) Description  ID Codes  It is 2084 and the year of Big Brother has finally arrived, albeit a century l

uva 146 ID Codes(求下一个排列)水水水

分别利用STL中的next_permutation和它的实现原理来写: next_permutation: <span style="font-family:Courier New;font-size:18px;">#include<stdio.h> #include<stdlib.h> #include<string.h> #include<algorithm> using namespace std; int main()

UVA 146 ID code(next_permutation的运用)

ID code 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

UVa 146 ID码

题意:输出一个排列的后继排列,如果是最大的降序排列,则输出没有后继. 思路:调用STL中的next_permutation()函数即可.不过这个函数在求后继时是一个循环状态,即全升序是全降序的后继,循环回来了.所以在调用之前判断一下是否为全降序序列即可.       感觉用这个函数没什么技术含量,有时间用纯C写一个. Code: #include<cstdio> #include<algorithm> #include<cstring> using namespace

UVA - 146

 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 meas

POJ 1146:ID Codes

ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6281 Accepted: 3769 Description 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

寒假集训.ID Codes

ID Codes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status 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 citi