BNU OJ 51000 BQG's Random String

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn=10000+10;
char s[maxn];

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%s",s);
        int len=strlen(s);
        int ans=0;
        for(int i=0;s[i];i++)
        {
            if(i<len&&i+1<len&&i+2<len&&s[i]=='Q'&&s[i+1]=='A'&&s[i+2]=='Q')
        ans++;
        }
        printf("%d\n",ans);

    }
    return 0;
}

 

posted @ 2015-12-26 11:29  Fighting_Heart  阅读(134)  评论(0编辑  收藏  举报