题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
s = input() N = int(input()) ls = [] for i in range(0, len(s)): ls.append(s[i : i + N]) #print(ls) lst = [] for i in ls: if len(i) == N: lst.append(i) #print(lst) lsd = [] p = 0 for i in lst: if ((i.count("G")) + (i.count("C"))) / len(i) > p: lsd.append(((i.count("G")) + (i.count("C"))) / len(i)) print(lst[lsd.index(max(lsd))]) # 注意这个的写法