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

全部评论

相关推荐

xwqlikepsl:感觉很厉害啊,慢慢找
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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