蓝桥杯练习系统
1. 数树数
n,m = map(int,input().split())
arr = [[i for i in input()] for _ in range(m)]
s = 1
for i in range(m):
k = len(arr[i])
for j in range(k):
if arr[i][j] == 'R':
s += 2**(k-1-j)
print(s)
s = 1
往二进制上靠
2. 三带一
n = int(input())
arr = [[i for i in input()] for _ in range(n)]
for i in range(n):
arr[i] = sorted(arr[i])
if arr[i].count(arr[i][0]) == 3 :
print("Yes")
elif arr[i].count(arr[i][3]) == 3:
print("Yes")
else:
print("No")
列表中用count(),很好用