题解 | #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)

全部评论

相关推荐

迷茫的大四🐶:自信一点,我认为你可以拿到50k,低于50k完全配不上你的能力,兄弟,不要被他们骗了,你可以的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务