题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
python3简单易懂
# 求字符串GC-Ratio是多少 def func(s): res = 0 for i in s: if i == 'A' or i == 'T': res += 0.5 else: res += 1 return res while True: try: Ratio = 0 p = '' D = input() n = int(input()) #GC-Ratio最大的时候,将子序列存起来 for i in range(len(D) - n + 1): s = D[i:i+n] if func(s) > Ratio: Ratio = func(s) p = s print(p) except: break