题解 | #DNA序列#

DNA序列

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

while True:
    try:
        a = input()
        n = int(input())
        res = []
        d = {}
        s = []
        #取出所有子序列
        for i in range(len(a)-n+1): #注意i的取值范围,保证不能取到短于n的序列
            res.append(a[i:i+n])
        #计算CG比
        for j in res:
            ng = j.count('G')
            nc = j.count('C')
            d[j] = (ng+nc)/len(j)
        #找到最大CG比的子序列
        maxi = max(d.values())
        for j in res:
            if d[j] == maxi:
                s.append(j)
        #输出最先出现的
        print(s[0])
            
    except:
        break
全部评论

相关推荐

面向对象的火龙果很爱...:去吃一顿炸鸡就走
点赞 评论 收藏
分享
05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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