#include <iostream> #include <string> using namespace std; int main() { string s; int n; while (cin >> s >> n) { int left = 0, right = 0; double gc_num = 0; double max_ratio = 0; int start = 0; while (right < s.size()) { if (s[right] == 'G' || s[right] == 'C') gc_num++; int len = right-left+1; if (len > n) { if (s[left] == 'G' || s[left] == 'C') gc_num--; left++; } double ratio = gc_num / n; if (ratio > max_ratio) { max_ratio = ratio; start = left; } right++; } cout << s.substr(start, n) << endl; } return 0; }</string></iostream>
1

相关推荐

不愿透露姓名的神秘牛友
06-04 15:20
牛客61197583...:看到室友一个个没怎么学通过关系直接入职或者接到面试,真的很难受。八股不知道背了多少遍,hot100也刷了1.5遍了,但就是没有面试的机会,唉
点赞 评论 收藏
分享
投递长鑫存储等公司8个岗位
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务