标签:string 总结 str std using == 溢出 ios 相加
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 100010;
const int inf = 1000000007;
int leftNump[maxn] = {0};
string str;
int main(){
getline(cin, str);
int len = str.length();
for(int i = 0; i < len; i++){
if(i > 0) leftNump[i] = leftNump[i-1];
if(str[i] == 'P'){
leftNump[i]++;
}
}
int ans = 0, rightNumT = 0;
for(int i = len-1; i >= 0; i--){
if(str[i] == 'T') rightNumT++;
else if(str[i] == 'A'){
ans = (ans + leftNump[i] * rightNumT) % inf;
}
}
cout << ans;
return 0;
}
标签:string 总结 str std using == 溢出 ios 相加
原文地址:https://www.cnblogs.com/tsruixi/p/11883661.html