zoukankan      html  css  js  c++  java
  • 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;
    }
     
  • 相关阅读:
    关于ajax无刷新分页 vue
    ajax无刷新分页
    querylist采集 爬虫
    201703-1 分蛋糕 Java
    201612-2 工资计算 Java
    201612-1 中间数 Java
    201609-2 火车购票 Java
    201609-1 最大波动 Java
    201604-2 俄罗斯方块 Java
    201604-1 折点计数 Java
  • 原文地址:https://www.cnblogs.com/guanwen769aaaa/p/11223867.html
Copyright © 2011-2022 走看看