Py||Who is the turn ?

题目描述

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')
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值