• sdnu 1312.Morse code


    1312.Morse code

    Time Limit: 1000 MS    Memory Limit: 32768 KB
    Total Submission(s): 39    Accepted Submission(s): 17

    Description

    Intelligencer Jason has just intercepted a cipher text, after seven days and nights he found the function how to crack the cipher, Jason’s ability of programming is pooooooor, so he comes to you to do him a favor.

          May you will not accept the request, but you must to do these job because Jason has just recommend you to the XiDada.

          Encryption Format:

     

     

    Followed by the rule of encryption format:The plaintext is ” ACM_GREATER_NY_REGION”, after encrypted the cipher is “.- -.-. -- ..-- --. .-. . .- - . .-. ..-- -. -.-- ..-- .-. . --. .. --- -.”It is illegibility! You can decrypt the cipher “.--.-.--” to “ACM” or “ANY”, so Jason marked the cipher characters which need to be decrypted together by a series of numbers, like “.--.-.--242”, each number represents the length of the characters after encrypted into the cipher, so the cipher can be “ACM”.

    You think it will be over? No! Jason hates the programmer, so raise the lever of the difficulty.

    Before you decrypt the cipher in accordance with the number followed by the cipher you need to reverse these numbers.Like that:

    Cipher:                “AKADTOF_IBOETATUK_IJN”

    Middle_Cipher:  “.--.-.--..----..-...--..-...---.-.--..--.-..--...----.232313442431121334242”

    Plaintext:            “ACM_GREATER_NY_REGION”

    Input

    Cipher(the length is no more than 100).

    Output

    Plaintext

    Sample Input

    AKADTOF_IBOETATUK_IJN

    Sample Output

    ACM_GREATER_NY_REGION

    Source

    Unknown
    #include<bits/stdc++.h>
    using namespace std;
    string s[200];
    void init()
    {
        s['A']=".-";
        s['B']="-...";
        s['C']="-.-.";
        s['D']="-..";
        s['E']=".";
        s['F']="..-.";
        s['G']="--.";
        s['H']="....";
        s['I']="..";
        s['J']=".---";
        s['K']="-.-";
        s['L']=".-..";
        s['M']="--";
        s['N']="-.";
        s['O']="---";
        s['P']=".--.";
        s['Q']="--.-";
        s['R']=".-.";
        s['S']="...";
        s['T']="-";
        s['U']="..-";
        s['V']="...-";
        s['W']=".--";
        s['X']="-..-";
        s['Y']="-.--";
        s['Z']="--..";
        s['_']="..--";
        s[',']=".-.-";
        s['.']="---.";
        s['?']="----";
    }
    int main()
    {
        string ss;
        init();
        int a[1000];
        while(cin>>ss)
        {
            string ans,tmp;
            memset(a,0,sizeof(a));
            for(int i=0;i<ss.length();++i)
            {
                tmp+=s[ss[i]];///...---...
                a[i]=s[ss[i]].length();///232323
            }
            reverse(a,a+ss.length());
            for(int i=0;i<ss.length();++i)
            {
                string tt(tmp,0,a[i]);
                tmp.erase(0,a[i]);
                for(int i=0;i<='z';i++)
                {
                    if(s[i]==tt)
                    {
                        ans+=(char)i;
                        break;
                    }
                }
            }
            cout<<ans<<endl;
        }
        return 0;
    }
     
  • 相关阅读:
    浅谈HTML5单页面架构(一)——requirejs + angular + angular-route
    嵌入式开发之web---vue 前端 注册登录login
    嵌入式开发之web---vue 前端 admin 后台管理系统
    嵌入式开发之web---vue-demo webstorm goahead 嵌入式智能设备
    嵌入式开发之web---vue vscode和vue webstorm 开发环境搭建
    多媒体开发之h264---h264格式说明
    嵌入式开发之内核内存异常排查---关闭oom killer
    Elasticsearch cat api的用法
    Django Mysql SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
    Django-基础-2-ORM
  • 原文地址:https://www.cnblogs.com/guanwen769aaaa/p/11223867.html
Copyright © 2020-2023  润新知