滑动数组的方法,从0位开始遍历,子串末尾是"G"or"C",则计数+1; 子串数组滑动到下一位之前,如果子串首位是"G"or"C",则计数-1 while True: try: s = input() L = int(input()) # sub = deque([], L) sub = [] # len = L GC_i, tmp, res = 0, 0, -1 for i in range(len(s)): sub.append(s[i]) ...