21089_CardTrick

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

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

Pro.ID

21089

Title

Card Trick

Title链接

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

AC

0

Submit

388

Ratio

0.00%

时间&空间限制

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

    The following card trick is performed by a Magician and the Assistant. The Assistant asks a member of the audience to choose 5 cards from a standard deck of 52 playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K of C[lubs], D[iamonds], H[earts] and S[pades]). After examining the cards, the Assistant gives one of the cards back to the audience member and then hands the remaining cards to the Magician, one at a time in a specific order. After suitable mumbo-jumbo, the Magician identifies the (fifth) card held by the audience member.
    The Magician determines the card as follows:
    The order of the cards in the deck is determined first by the value and for cards of the same value by the suit (both in the order given above). So the total order of cards is: AC, AD, AH, AS, 2C,2D, … , KH, KS
    1. Remember the suit and value of the first card.
    2. Among the remaining three cards find the position of the smallest card (in the above order). Add this position (1, 2, or 3) to the value of the first card.
    3. If the larger two of the last three cards are not in order, add 3 to the result of step 2.
    4. The missing card has the same suit as the first card and value that computed in step 3 wrapping around if necessary.
    For example:
    QH, 10D, 10C, 4D
    Smallest of the last 3 cards is 4D in place 3. 10D and 10C are out of order so add 3 + 3 to Q. Wrapping around the missing card is 5H.
    This problem is to write a program to perform the function of the Assistant.

    输入

    The first line of the input consists of a positive integer n, which is the number of datasets that follow. Each of the n following lines contains one data set. The dataset is a sequence of 5 cards separated by a space. Each card is given by a one or two character value and a one character suit as described in the first paragraph.

    输出

    Description
    The following card trick is performed by a Magician and the Assistant. The Assistant asks a member of the audience to choose 5 cards from a standard deck of 52 playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K of C[lubs], D[iamonds], H[earts] and S[pades]). After examining the cards, the Assistant gives one of the cards back to the audience member and then hands the remaining cards to the Magician, one at a time in a specific order. After suitable mumbo-jumbo, the Magician identifies the (fifth) card held by the audience member.
    The Magician determines the card as follows:
    The order of the cards in the deck is determined first by the value and for cards of the same value by the suit (both in the order given above). So the total order of cards is: AC, AD, AH, AS, 2C,2D, … , KH, KS
    1. Remember the suit and value of the first card.
    2. Among the remaining three cards find the position of the smallest card (in the above order). Add this position (1, 2, or 3) to the value of the first card.
    3. If the larger two of the last three cards are not in order, add 3 to the result of step 2.
    4. The missing card has the same suit as the first card and value that computed in step 3 wrapping around if necessary.
    For example:
    QH, 10D, 10C, 4D
    Smallest of the last 3 cards is 4D in place 3. 10D and 10C are out of order so add 3 + 3 to Q. Wrapping around the missing card is 5H.
    This problem is to write a program to perform the function of the Assistant.
    Input
    The first line of the input consists of a positive integer n, which is the number of datasets that follow. Each of the n following lines contains one data set. The dataset is a sequence of 5 cards separated by a space. Each card is given by a one or two character value and a one character suit as described in the first paragraph.
    Output
    For each dataset, output on a single line the card the Assistant gives back to the audience member, followed by the four remaining cards in the order they should be presented to the Magician so that she can determine the card that was given back to the audience member.
    Sample Input
    2
    QH 5H 10C 4D 10D
    5C KS 8D 7H 6C
    Sample Output
    5H QH 10D 10C 4D
    6C 5C 7H 8D KS
    Source

    样例输入

    2
    QH 5H 10C 4D 10D
    5C KS 8D 7H 6C

    样例输出

    5H QH 10D 10C 4D
    6C 5C 7H 8D KS

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部