21075_Stringer

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

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

Pro.ID

21075

Title

Stringer

Title链接

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

AC

0

Submit

899

Ratio

0.00%

时间&空间限制

  • Time Limit: 6000/2000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Imagine a list of strings that are all built from the first N letters of the alphabet, which all have a predetermined number of a’s, a predetermined (but possibly different) number of b’s, and so on.
    Imagine that it’s sorted in alphabetical order, and numbered, starting at 0. What’s the Kth string in the list?
    For example, look at all strings of a’s and b’s (N=2) with 2 a’s and 3 b’s:

    If K=5, then the Kth string in the list would be babab.

    输入

    Input will consist of multiple datasets. Each dataset consists of two lines.
    On the first line are two integers, N (1  <=  N  <=  20) and K (0 <= K < m), where N is the number of letters of the alphabet used, K is the index of the list element that should be found, and m (not given explicitly in the input) denotes the number of strings make up the list.
    m, the number of strings in the list may be very, very large (too large to permit generating the whole list), but the input will be chosen so that m and K will each fit in a 32 bit integer.
    On the second line will be N non-negative integers, which represent the number of a’s, the number of b’s and so on. The sum of these integers is guaranteed to be at least 1 and no greater than 50.
    End of input is indicated by a line with two zeros.

    输出

    Description
    Imagine a list of strings that are all built from the first N letters of the alphabet, which all have a predetermined number of a’s, a predetermined (but possibly different) number of b’s, and so on.
    Imagine that it’s sorted in alphabetical order, and numbered, starting at 0. What’s the Kth string in the list?
    For example, look at all strings of a’s and b’s (N=2) with 2 a’s and 3 b’s:

    If K=5, then the Kth string in the list would be babab.
    Input
    Input will consist of multiple datasets. Each dataset consists of two lines.
    On the first line are two integers, N (1  <=  N  <=  20) and K (0 <= K < m), where N is the number of letters of the alphabet used, K is the index of the list element that should be found, and m (not given explicitly in the input) denotes the number of strings make up the list.
    m, the number of strings in the list may be very, very large (too large to permit generating the whole list), but the input will be chosen so that m and K will each fit in a 32 bit integer.
    On the second line will be N non-negative integers, which represent the number of a’s, the number of b’s and so on. The sum of these integers is guaranteed to be at least 1 and no greater than 50.
    End of input is indicated by a line with two zeros.
    Output
    Output each answer string on its own line. Do not print any extra white space. Do not print any blank lines between answers.
    Sample Input
    2 5
    2 3
    3 0
    2 3 1
    0 0
    Sample Output
    babab
    aabbbc
    Source

    样例输入

    2 5
    2 3
    3 0
    2 3 1
    0 0

    样例输出

    babab
    aabbbc

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部