题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a?tpId=37&tqId=21286&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
import sys
s = input()
length =int(input())
L=[]
#for i in range(len(s)):
#遍历所有的字串
i=0
while i+ length < len(s)+1:
L.append(s[i:i+length])
i+=1
#计算字串的GC_Ratio
#保留最大值,并输出,如果小于等于当前最大值,不用更新
maxGC_Ratio =0
for x in L:
current_Ratio=(x.count("G")+x.count("C"))/length
if maxGC_Ratio < current_Ratio:
maxGC_Ratio=current_Ratio
maxGC_Ratio_string=x
else:
pass
print(maxGC_Ratio_string)
科大讯飞公司氛围 459人发布