Py||Who is the turn ?

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/Lhw_666/article/details/102754633

题目描述

Ping Pang is very popular in China. Assuming that A and B are playing table tennis, each time A is the first serve the Ping Pang ball, then the rules for serving the ball are as follows:

  1. One player scores 11 points and the other player scores less than or equal to 9 points. The game ends and the former wins;
  2. If there is a score of 10:10, then the game enters the playoffs, and the two players take turns to serve the ball. When the difference is 2 points, the game is over and the player with higher score is won.
  3. In other cases, the two players serve 2 balls in turn;

Please write a program to determine who is serving based on the current score?

输入
The input includes multiple lines of data, each line of data including two positive integers, a and b, representing the scores of players A and B in the Ping Pang game, 0 <= a, b <= 100.
输出
For each line of input, is the output of the next serving player, A or B? If the game is over, output Game Over.
样例输入 Copy
0 0
0 2
11 9
样例输出 Copy
A
B
Game Over

import sys
while True:
    a,b=map(int,input().split())
    if((a==11 or b==11) and (11-a>=2 or 11-b>=2)):
        print('Game Over')
    else:
        if a>=10 and b>=10:
            if a-b==2 or b-a==2:
                print('Game Over')
            else:
                if a==b:
                    print('A')
                else:
                    print('B')
        else:
            if (a+b)%4<=1:
                print('A')
            else:
                print('B')

猜你喜欢

转载自blog.csdn.net/Lhw_666/article/details/102754633