题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
while True: try: s = input() n = int(input()) ls = [] for i in range(len(s)-n+1): ls.append(s[i:i+n]) GC_ratio = {} for i in ls: gnum = i.count("G") cnum = i.count("C") GC = gnum + cnum GC_ratio[i] = GC/n sorted_result = sorted(GC_ratio.items(), key = lambda x:x[1], reverse = True) print(sorted_result[0][0]) except: break