zoukankan      html  css  js  c++  java
  • Rhyme scheme

    •  31.43%
    •  1000ms
    •  65536K
     

    A rhyme scheme is the pattern of rhymes at the end of each line of a poem or song. It is usually referred to by using letters to indicate which lines rhyme; lines designated with the same letter all rhyme with each other.

    e.g., the following "poem'' of 44 lines has an associated rhyme scheme "ABBA''

    1 —— 9999 bugs in the code A

    2 —— Fix one line B

    3 —— Should be fine B

    4 —— 100100 bugs in the code A

    This essentially means that line 11 and 44 rhyme together and line 22 and 33 rhyme together.

    The number of different possible rhyme schemes for an nn-line poem is given by the Bell numbers. For example, B_3 = 5B3=5, it means there are five rhyme schemes for a three-line poem: AAA, AAB, ABA, ABB, and ABC.

    The question is to output the kk-th rhyme scheme in alphabetical order for a poem of nn lines.For example: the first rhyme scheme of a three-line poem is "AAA'', the fourth rhyme scheme of a three-line poem is ABB''.

    InputFile

    The first line of the input gives the number of test cases, TT (1 leq T leq 100001T10000). TT test cases follow.

    Each test case contains a line with two integers nn and kk.

    1 leq n leq 26, 1 leq k leq B_n1n26,1kBn (B_nBn is the nn-th of Bell numbers)

    OutputFile

    For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is the rhyme scheme contains uppercase letters.

    样例输入

    7
    1 1
    2 1
    3 1
    3 2
    3 3
    3 4
    3 5
    

    样例输出

    Case #1: A
    Case #2: AA
    Case #3: AAA
    Case #4: AAB
    Case #5: ABA
    Case #6: ABB
    Case #7: ABC
    
  • 相关阅读:
    Linux内核设计第三周学习总结 跟踪分析Linux内核的启动过程
    Linux内核设计第二周学习总结 完成一个简单的时间片轮转多道程序内核代码
    Linux内核设计第一周学习总结 计算机如何工作
    信息安全系统设计基础期末总结
    信息安全系统设计基础第十四周学习总结
    信息安全系统设计基础第十三周学习总结
    20135310陈巧然 20135305姚歌 实验四:外设驱动程序设计
    linux内核设计与实现一书阅读整理 之第一二章整合
    20135239 益西拉姆 linux内核分析 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
    20135239 益西拉姆 linux内核分析 跟踪分析Linux内核的启动过程
  • 原文地址:https://www.cnblogs.com/czy-power/p/11525174.html
Copyright © 2011-2022 走看看