B1040

#include<stdio.h>
const int N = 1000000007;
char s[100010];
int count[2][100010];
int main() {
	scanf("%s",s);
	int i=0,num=0;
	while(s[i]!='\0') {
		if(s[i]=='P') num++;
		if(s[i]=='A') count[0][i]=num;
		++i;
	}
	int len=i;
	--i;
	num=0;
	while(i>-1) {
		if(s[i]=='T') num++;
		if(s[i]=='A') count[1][i]=num;
		--i;
	}
	int re=0;
	for(i=0; i<len; ++i) {
		re+=count[0][i]*count[1][i];
		re=re%N;
	}
	printf("%d",re);
//	for(i=0; i<len; ++i) printf("%d ",count[0][i]);
//	printf("\n");
//	for(i=0; i<len; ++i) printf("%d ",count[1][i]);
//	printf("\n");
	return 0;
}
上一篇:应用fiddler,使用har2case 将api参数转成yaml格式


下一篇:【算法笔记】B1040 有几个PAT