#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
string s; cin>>s;
long long wyn=0;
int sz=s.size(), ltr=-1;
for(int i=0; i<sz; i++){
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' || s[i]=='y')s[i]='a';
else s[i]='b';
if(i>=2 && s[i]==s[i-1] && s[i-1]==s[i-2]){
wyn+=max(i-ltr-2, 1)*(sz-i);
ltr=i;
}
}
cout<<wyn;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin>>s; long long wyn=0; int sz=s.size(), ltr=-1; for(int i=0; i<sz; i++){ if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' || s[i]=='y')s[i]='a'; else s[i]='b'; if(i>=2 && s[i]==s[i-1] && s[i-1]==s[i-2]){ wyn+=max(i-ltr-2, 1)*(sz-i); ltr=i; } } cout<<wyn; } |
English