1040 有几个PAT(25)(25 分)

#include 
#include
#include
#include 
typedef long long ll ;
using namespace std;
int main(){
	char s[100001];
	cin>>s;
	ll sum=0;
	ll count=0;
	ll countp=0;
	ll countt=0;
	for(int i=0;s[i]!='\0';i++)
	{
		if (s[i] == 'T')
            countt++;
	}
	for(int i=0;s[i]!='\0';i++)
	{
		count=0;
		if(s[i]=='P')countp++;
		if(s[i]=='T')countt--;
		if(s[i]=='A'){
		count=(countp*countt)%1000000007;
		}
		sum+=count;
	}
	sum=sum%1000000007;
	cout<

 

你可能感兴趣的:(1040 有几个PAT(25)(25 分))