题解 | #DNA序列#

DNA序列

http://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a

def ratio(s):
    return (s.count("G")+s.count("C"))/len(s)
while True:
    try:
        n=0
        s=input().strip()
        l=int(input())
        str_list=[]
        for i in range(len(s)-l+1):
            if ratio(s[i:i+l])>n:
                str_list.append(s[i:i+l])
                n=ratio(s[i:i+l])
        print(str_list[-1])
    except:
        break

全部评论

相关推荐

03-26 12:00
已编辑
门头沟学院 Java
offer魅魔_oc...:100-200每天,你还要倒贴100
点赞 评论 收藏
分享
03-03 19:02
已编辑
东华理工大学 Node.js
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务