#include<cstdio>
#include<cstring>
using namespace std;
const int mode = 1000000007;
int main()
{
char str[100010];
int leftnum[100010] = { 0 };
scanf("%s", str);
int len = strlen(str);
for (int i = 0; i < len; i++)
{
if (i > 0 ) leftnum[i] = leftnum[i - 1];
if (str[i] == 'P') leftnum[i]++;
}
int rightnum=0,ans=0;
for (int i = len - 1; i > 0; i--)
{
if (str[i] == 'T')
{
rightnum++;
}
else if (str[i] == 'A')
{
ans = (ans + leftnum[i] * rightnum) % mode;
}
}
printf("%d", ans);
return 0;
}
A1093 Count PAT's (25 分)
最新推荐文章于 2022-02-09 15:26:24 发布