Hiho Interview Problems 2 register

Ended

Participants:465

Verdict:Accepted
Submitted:2014-09-14 15:07:09

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int Ta;
    cin>>Ta;
    while(Ta--)
    {
        string s;
        int k,d;
        cin>>s;
        cin>>k;
        if(k>=s.length()) cout<<"0"<<endl;
        else {
            int A,T,G,C,m,total=0;
            d=2*k-s.length();
            if(d<0) d=0;
            for(int i=0;i<k-d;++i)
            {
                A=T=G=C=m=0;
                int cur=i;
                while(cur<s.length())
                {
                    if(s[cur]=='A') A++;
                    else if(s[cur]=='T') T++;
                    else if(s[cur]=='G') G++;
                    else C++;
                    cur+=s.length()-k;
                }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX