21757_'BullsandCows'

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

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

Pro.ID

21757

Title

'Bulls and Cows'

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    You probably know the game "bulls and cows". Just in case, we explain the rules. The first player picks a four-digit number with all digits distinct (leading zero is allowed) and keeps it secret. The second player tries to guess the secret number. For each guess, the first player issues a response in the form "n bulls, m cows". A "bull" is a digit that is present in both the secret and the guess and occurs in the same position in both. A "cow" is a digit that is present in both numbers, but occurs in different positions.

    For example, if the first player picked 5071, and the second guessed 6012, the response would be "one bull, one cow". Here the "bull" is the digit 0, as it is in the second position in both numbers, and the "cow" is the digit 1, as it is in the fourth position in the secret, but in the third position in the guess.

    Write a program to count the number of cows and bulls for the given the secret and guess.

    输入

    The first line of the input file contains four digits, the number picked by the first player. The second line contains the number guessed by the second player in the same format.

    输出

    Description

    You probably know the game "bulls and cows". Just in case, we explain the rules. The first player picks a four-digit number with all digits distinct (leading zero is allowed) and keeps it secret. The second player tries to guess the secret number. For each guess, the first player issues a response in the form "n bulls, m cows". A "bull" is a digit that is present in both the secret and the guess and occurs in the same position in both. A "cow" is a digit that is present in both numbers, but occurs in different positions.

    For example, if the first player picked 5071, and the second guessed 6012, the response would be "one bull, one cow". Here the "bull" is the digit 0, as it is in the second position in both numbers, and the "cow" is the digit 1, as it is in the fourth position in the secret, but in the third position in the guess.

    Write a program to count the number of cows and bulls for the given the secret and guess.

    Input

    The first line of the input file contains four digits, the number picked by the first player. The second line contains the number guessed by the second player in the same format.

    Output

    The first and only line of the output file should contain two integers separated by a space, the number of "bulls" and the number of "cows".

    Sample Input

    Sample #1
    5071
    6012


    Sample #2
    4321
    4321


    Sample #3
    1980
    0879


    Sample #4
    1234
    5678

    Sample Output

    Sample #1
    1 1

    Sample #2
    4 0

    Sample #3
    0 3

    Sample #4
    0 0

    Source

    样例输入

    Sample #1
    5071
    6012


    Sample #2
    4321
    4321


    Sample #3
    1980
    0879


    Sample #4
    1234
    5678

    样例输出

    Sample #1
    1 1

    Sample #2
    4 0

    Sample #3
    0 3

    Sample #4
    0 0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部