愛奇藝編程題:DNA序列

題目:https://www.nowcoder.com/practice/ab900f183e054c6d8769f2df977223b5?tpId=90&tqId=30789&tPage=1&rp=1&ru=/ta/2018test&qru=/ta/2018test/question-ranking
#include <bits/stdc++.h>

using namespace std;

/*自己實(shí)現(xiàn)一遍pow函數(shù),求m的n次冪*/

int int_pow(int m,int n){

int ret = 1;

int tmp = m;

while(n){

if(n & 1){

ret *= tmp;

}

tmp *= tmp;

n >>= 1;

}

return ret;

}

int func(string s){

int n = s.size();

set<string> cur;

for(auto len = 1; len <= n;++len){

cur.clear();

for(auto start = 0;start <= n-len;++start){

cur.insert(s.substr(start,len));

}

int sz = cur.size();

if(sz < int_pow(4,len))

return len;

}

/*正常情況下不會(huì)走到這里,僅僅為了編譯通過*/

return -1;

}

int main(){

string s;

while(cin >> s){

cout<<func(s)<<endl;

}

return 0;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容