21436_EtaoinShrdlu

2022-5-16 18:19| 发布者: Hocassian| 查看: 27| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505261930800-Problem List-采集的数据-后羿采集器.html

Pro.ID

21436

Title

Etaoin Shrdlu

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21436

AC

15

Submit

23

Ratio

65.22%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    The relative frequency of characters in natural language texts is very important for cryptography. However, the statistics vary for different languages. Here are the top 9 characters sorted by their relative frequencies for several common languages:

    English: ETAOINSHR
    German:  ENIRSATUD
    French:  EAISTNRUL
    Spanish: EAOSNRILD
    Italian: EAIONLRTS
    Finnish: AITNESLOK
    Just as important as the relative frequencies of single characters are those of pairs of characters, so called digrams. Given several text samples, calculate the digrams with the top relative frequencies.

    输入

    The input contains several test cases. Each starts with a number n on a separate line, denoting the number of lines of the test case. The input is terminated by n=0. Otherwise, 1 ≤ n 64, and there follow n lines, each with a maximal length of 80 characters. The concatenation of these n lines, where the end-of-line characters are omitted, gives the text sample you have to examine. The text sample will contain printable ASCII characters only.

    输出

    Description

    The relative frequency of characters in natural language texts is very important for cryptography. However, the statistics vary for different languages. Here are the top 9 characters sorted by their relative frequencies for several common languages:

    English: ETAOINSHR
    German:  ENIRSATUD
    French:  EAISTNRUL
    Spanish: EAOSNRILD
    Italian: EAIONLRTS
    Finnish: AITNESLOK
    Just as important as the relative frequencies of single characters are those of pairs of characters, so called digrams. Given several text samples, calculate the digrams with the top relative frequencies.
    Input

    The input contains several test cases. Each starts with a number n on a separate line, denoting the number of lines of the test case. The input is terminated by n=0. Otherwise, 1 ≤ n 64, and there follow n lines, each with a maximal length of 80 characters. The concatenation of these n lines, where the end-of-line characters are omitted, gives the text sample you have to examine. The text sample will contain printable ASCII characters only.

    Output

    For each test case generate 5 lines containing the top 5 digrams together with their absolute and relative frequencies. Output the latter rounded to a precision of 6 decimal places. If two digrams should have the same frequency, sort them in (ASCII) lexicographical order. Output a blank line after each test case.

    Sample Input

    2
    Take a look at this!!
    !!siht ta kool a ekaT
    5
    P=NP
    Authors: A. Cookie, N. D. Fortune, L. Shalom
    Abstract: We give a PTAS algorithm for MaxSAT and apply the PCP-Theorem [3]
    Let F be a set of clauses. The following PTAS algorithm gives an optimal
    assignment for F:
    0

    Sample Output

    a 3 0.073171
    !! 3 0.073171
    a  3 0.073171
    t 2 0.048780
    oo 2 0.048780

    a 8 0.037209
    or 7 0.032558
    .  5 0.023256
    e  5 0.023256
    al 4 0.018605

    Source

    样例输入

    2
    Take a look at this!!
    !!siht ta kool a ekaT
    5
    P=NP
    Authors: A. Cookie, N. D. Fortune, L. Shalom
    Abstract: We give a PTAS algorithm for MaxSAT and apply the PCP-Theorem [3]
    Let F be a set of clauses. The following PTAS algorithm gives an optimal
    assignment for F:
    0

    样例输出

    a 3 0.073171
    !! 3 0.073171
    a  3 0.073171
    t 2 0.048780
    oo 2 0.048780

    a 8 0.037209
    or 7 0.032558
    .  5 0.023256
    e  5 0.023256
    al 4 0.018605

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部