1093. Count PAT's (25)
简介:
#include #include #include using namespace std;int main() { string s; cin >> s; long long sum = 0, p = 0, t = 0; for (int i = 0; i < s.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
string s;
cin >> s;
long long sum = 0, p = 0, t = 0;
for (int i = 0; i < s.length(); i++) {
if(s[i] == 'T') t++;
}
for (int i = 0; i < s.length(); i++) {
if(s[i] == 'P') p++;
if(s[i] == 'T') t--;
if(s[i] == 'A') sum = (sum + p * t % 1000000007) % 1000000007;
}
cout << sum << endl;
return 0;
}