题解
2025-04-30 15:46:07
发布于:四川
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
string s;
long long n[1000010];
long long cnt, m;
int main() {
cin >> s;
for(int i = 1; i <= 1000000; i++) n[i] = n[i-1] + i;
for(int i = 0; i < s.size(); i++) {
if(s[i] == 'z') m++;
if(s[i] == 'y') cnt += n[m-1];
}
cout << cnt;
return 0;
}
这里空空如也
有帮助,赞一个