1040 有几个PAT (25分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805282389999616
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <string> #include <cstring> typedef long long ll; using namespace std; int main() { ll sum=0,cou_p=0,cou_t=0; string str; cin>>str; for(int i=0;i<str.length();i++) if(str[i]==‘T‘) cou_t++; for(int i=0;i<str.length();i++) { if(str[i]==‘P‘) cou_p++; else if(str[i]==‘T‘) cou_t--; else if(str[i]==‘A‘) sum+=(cou_p*cou_t); } printf("%d\n",sum%1000000007); return 0; }
原文地址:https://www.cnblogs.com/jianqiao123/p/12234175.html
时间: 2024-10-10 11:13:55