loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cards = list(input())
rounds = int(input())
lastresult = ""

for i, c in enumerate(cards):
    if c == "A":
        cards[i] = 11
    elif c in "TJQK":
        cards[i] = 10
    else:
        cards[i] = int(c)

for _ in range(rounds):
    hand = []
    for _ in range(2):
        hand.append(cards.pop(0))

    while True:
        s = sum(hand)
        l = len(hand)
        if l == 2 and s == 21:
            lastresult = "A"
            break
        elif l == 5 and s <= 21:
            lastresult = "B"
            break
        elif 17 <= s <= 21:
            lastresult = "C{:02d}".format(s)
            break
        elif s > 21:
            lastresult = "D"
            break
        else:
            hand.append(cards.pop(0))

print(lastresult)