21176_Run,Run,RunaroundNumbers

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

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

Pro.ID

21176

Title

Run, Run, Runaround Numbers

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    An N-digit runaround number is characterized as follows:

    • It is an integer with exactly N digits, each of which is between 1 and 9, inclusively.
    • The digits form a sequence with each digit telling where the next digit in the sequence occurs. This is done by giving the number of digits to the right of the digit where the next digit in the sequence occurs. If necessary, counting wraps around from the rightmost digit back to the leftmost.
    • The leftmost digit in the number is the first digit in the sequence, and the sequence must return to this digit after all digits in the number have been used exactly once.
    • No digit will appear more than once in the number. This rule was accidentally left out of the problem description at the competition.
    For example, consider the number 81362. To verify that this is a runaround number, we use the steps shown below:

    1. Start with the leftmost digit, 8
      8 1 3 6 2
      -
    2. Count 8 digits to the right, ending on 6 (note the wraparound).
      8 1 3 6 2
      -     -
    3. Count 6 digits to the right, ending on 2.
      8 1 3 6 2
      -     - -
    4. Count 2 digits to the right, ending on 1.
      8 1 3 6 2
      - -   - -
    5. Count 1 digit to the right, ending on 3.
      8 1 3 6 2
      - - - - -
    6. Count 3 digits to the right, ending on 8, where we began.
      8 1 3 6 2
      = - - - -

    输入

    In this problem you will be provided with one or more input lines, each with a single integer R having between 2 and 7 digits followed immediately by the end of line. For each such number, determine the smallest runaround number that is equal to or greater than R. There will always be such a number for each of the input numbers.

    The last line of the input will contain only the digit 0 in column 1.

    输出

    Description
    An N-digit runaround number is characterized as follows:

    • It is an integer with exactly N digits, each of which is between 1 and 9, inclusively.
    • The digits form a sequence with each digit telling where the next digit in the sequence occurs. This is done by giving the number of digits to the right of the digit where the next digit in the sequence occurs. If necessary, counting wraps around from the rightmost digit back to the leftmost.
    • The leftmost digit in the number is the first digit in the sequence, and the sequence must return to this digit after all digits in the number have been used exactly once.
    • No digit will appear more than once in the number. This rule was accidentally left out of the problem description at the competition.
    For example, consider the number 81362. To verify that this is a runaround number, we use the steps shown below:

    1. Start with the leftmost digit, 8
      8 1 3 6 2
      -
    2. Count 8 digits to the right, ending on 6 (note the wraparound).
      8 1 3 6 2
      -     -
    3. Count 6 digits to the right, ending on 2.
      8 1 3 6 2
      -     - -
    4. Count 2 digits to the right, ending on 1.
      8 1 3 6 2
      - -   - -
    5. Count 1 digit to the right, ending on 3.
      8 1 3 6 2
      - - - - -
    6. Count 3 digits to the right, ending on 8, where we began.
      8 1 3 6 2
      = - - - -
    Input

    In this problem you will be provided with one or more input lines, each with a single integer R having between 2 and 7 digits followed immediately by the end of line. For each such number, determine the smallest runaround number that is equal to or greater than R. There will always be such a number for each of the input numbers.

    The last line of the input will contain only the digit 0 in column 1.

    Output
    Display the resulting number in the format illustrated below.
    Sample Input
    12
    123
    1234
    81111
    82222
    83333
    911111
    7654321
    0 
    Sample Output
    Case 1: 13
    Case 2: 147
    Case 3: 1263
    Case 4: 81236
    Case 5: 83491
    Case 6: 83491
    Case 7: 913425
    Case 8: 8124956 
    Source

    样例输入

    12
    123
    1234
    81111
    82222
    83333
    911111
    7654321
    0 

    样例输出

    Case 1: 13
    Case 2: 147
    Case 3: 1263
    Case 4: 81236
    Case 5: 83491
    Case 6: 83491
    Case 7: 913425
    Case 8: 8124956 

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部