22528_Undercu

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

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

Pro.ID

22528

Title

Undercut

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Undercut is a card game where two players each have five cards numbered one through five. At each round, each player selects a card, then simultaneously reveals it. If the cards are of equal value, there is no score. Otherwise, there are two cases: the two cards are exactly one point apart (this is called an undercut), or the cards are more than one point apart. In the latter case, the person revealing the larger of the cards gets the number of points on the larger card. In the case of an undercut the player with the lower card gets the sum of the two cards. The exception to this is when the cards are 1 and 2, in which case the player with the lower card gets 6 points (instead of only 3 points). After each round, the cards are returned to the hands and they play another round.

    For example, if there are 5 rounds and player A plays (in this order) 5, 3, 1, 3, 5 and player B plays 3, 3, 3, 3, 4, then the scoring for each round would be: A gets 5 points, no points, B gets 3 points, no points, B gets 9 points. The totals would be A: 5, B: 12.

    In this problem you will be given card plays for both players and must determine the final scores.

    输入

    There will be multiple input instances. Each instance will be one game. The first line of input for a game will be an integer n ≤ 20. (A value of n = 0 terminates input.) The next two lines will each contain n integers between 1 and 5 inclusive indicating the cards played on each of n rounds. The first line are player A's card plays and the second line are player B's card plays.

    输出

    Description

    Undercut is a card game where two players each have five cards numbered one through five. At each round, each player selects a card, then simultaneously reveals it. If the cards are of equal value, there is no score. Otherwise, there are two cases: the two cards are exactly one point apart (this is called an undercut), or the cards are more than one point apart. In the latter case, the person revealing the larger of the cards gets the number of points on the larger card. In the case of an undercut the player with the lower card gets the sum of the two cards. The exception to this is when the cards are 1 and 2, in which case the player with the lower card gets 6 points (instead of only 3 points). After each round, the cards are returned to the hands and they play another round.

    For example, if there are 5 rounds and player A plays (in this order) 5, 3, 1, 3, 5 and player B plays 3, 3, 3, 3, 4, then the scoring for each round would be: A gets 5 points, no points, B gets 3 points, no points, B gets 9 points. The totals would be A: 5, B: 12.

    In this problem you will be given card plays for both players and must determine the final scores.

    Input

    There will be multiple input instances. Each instance will be one game. The first line of input for a game will be an integer n ≤ 20. (A value of n = 0 terminates input.) The next two lines will each contain n integers between 1 and 5 inclusive indicating the cards played on each of n rounds. The first line are player A's card plays and the second line are player B's card plays.

    Output

    Each input instance should generate one line of output of the form:

    A has a points. B has b points.

    where the value of a and b are for you to determine. A blank line should separate output lines.

    Sample Input

    5
    5 3 1 3 5
    3 3 3 3 4
    4
    2 3 1 1
    1 5 5 5
    0

    Sample Output

    A has 5 points. B has 12 points.
    A has 0 points. B has 21 points.

    Source

    样例输入

    5
    5 3 1 3 5
    3 3 3 3 4
    4
    2 3 1 1
    1 5 5 5
    0

    样例输出

    A has 5 points. B has 12 points.
    A has 0 points. B has 21 points.

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部