PAT 1093. Count PAT's

来源:互联网 发布:blued同志软件下载 编辑:程序博客网 时间:2024/05/20 02:52

CODE:

#include<cstdio>#include<cstring>#define LL long longusing namespace std;const int MOD=1000000007;const int N=1e5;char s[N+5];int main(){    while(scanf("%s",s)==1)    {        LL p=0;        LL pa=0;        LL pat=0;        int len=strlen(s);        for(int i=0;i<len;i++)        {            if(s[i]=='P')            {                p++;            }            if(s[i]=='A')            {                pa=pa+p;            }            if(s[i]=='T')            {                pat=pat+pa;            }        }        printf("%d\n",pat%MOD);    }    return 0;}


0 0