#include <bits/stdc++.h> using namespace std; bool sam(char a){ switch (a){ case 'e': case 'y': case 'u': case 'i': case 'o': case 'a': return true; default: return false; } } int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); string s; cin >> s; unsigned long long odp = (unsigned long long)(s.size())*(unsigned long long)(s.size()+1)/2; unsigned long long p=0,l=0; for(int i=2;i<s.size();i++){ if((sam(s[i])&&sam(s[i-1])&&sam(s[i-2])) || !(sam(s[i])||sam(s[i-1])||sam(s[i-2]))){ p=i; odp -= (p-l)*(p-l+1)/2; odp ++; l=p-1; } } p=s.size(); odp -= (p-l)*(p-l+1)/2; cout << odp; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <bits/stdc++.h> using namespace std; bool sam(char a){ switch (a){ case 'e': case 'y': case 'u': case 'i': case 'o': case 'a': return true; default: return false; } } int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); string s; cin >> s; unsigned long long odp = (unsigned long long)(s.size())*(unsigned long long)(s.size()+1)/2; unsigned long long p=0,l=0; for(int i=2;i<s.size();i++){ if((sam(s[i])&&sam(s[i-1])&&sam(s[i-2])) || !(sam(s[i])||sam(s[i-1])||sam(s[i-2]))){ p=i; odp -= (p-l)*(p-l+1)/2; odp ++; l=p-1; } } p=s.size(); odp -= (p-l)*(p-l+1)/2; cout << odp; } |