zoukankan      html  css  js  c++  java
  • Code obfuscation

    Description

    Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.

    To obfuscate the code, Kostya first looks at the first variable name used in his program and replaces all its occurrences with a single symbol a, then he looks at the second variable name that has not been replaced yet, and replaces all its occurrences with b, and so on. Kostya is well-mannered, so he doesn't use any one-letter names before obfuscation. Moreover, there are at most 26 unique identifiers in his programs.

    You are given a list of identifiers of some program with removed spaces and line breaks. Check if this program can be a result of Kostya's obfuscation.

    Input

    In the only line of input there is a string S of lowercase English letters (1 ≤ |S| ≤ 500) — the identifiers of a program with removed whitespace characters.

    Output

    If this program can be a result of Kostya's obfuscation, print "YES" (without quotes), otherwise print "NO".

    Sample Input

    Input

    abacaba
    

    Output

    YES
    

    Input

    jinotega
    

    Output

    NO
    题目大意:给出一个字符串,每一个字母都要小于等于前面的最大值加一,否则输出NO(第一个必须是a)
    #include <stdio.h>
    #include <string.h>
    int main()
    {
        char e[1000];
        int i,p=0,max,x;
        while(gets(e))
        {
            x=0;
            p=strlen(e);
            if(e[0]!='a')
            {
                printf("NO
    ");
                continue;
            }
            max=e[0];
            for(i=0;i<p;i++)
            {
                if(e[i]<max+1)
                    continue;
                else
                if(e[i]==max+1)
                   max+=1;
                else
                {
                    x=1;
                    break;
                }
            }
            if(x==0)
               printf("YES
    ");
            else
                printf("NO
    ");
        }
        return 0;
    }
  • 相关阅读:
    Linux dd 命令
    excel合并单元格数据读取
    判断字符串是否以中文字符开头
    列表嵌套字典去重统计
    【转载】【DBDK】dpdk大页内存原理
    【LinuxShell】ps 命令浅析
    【LinuxShell】free 命令详解
    【网络安全】IOC概念浅析
    【转载】【网络安全】渗透中 PoC、Exp、Payload 与 Shellcode 的区别
    【SVN】windows 下的SVN常见问题及其解决方法
  • 原文地址:https://www.cnblogs.com/zcy19990813/p/9702830.html
Copyright © 2011-2022 走看看