#include<iostream> #include<string> #include<vector> using namespace std; /* bool sprawdz(int i, int k) { //cout<<i<<" "<<k<<"\n"; for(int j = 0; j < k-2; ++j) { if(slowo[i+j] == 'a' || slowo[i+j] == 'e' || slowo[i+j] == 'i' || slowo[i+j] == 'o'|| slowo[i+j] == 'u' || slowo[i+j] == 'y') if(slowo[i+j+1] == 'a' || slowo[i+j+1] == 'e' || slowo[i+j+1] == 'i' || slowo[i+j+1] == 'o'|| slowo[i+j+1] == 'u' || slowo[i+j+1] == 'y') if(slowo[i+j+2] == 'a' || slowo[i+j+2] == 'e' || slowo[i+j+2] == 'i' || slowo[i+j+2] == 'o'|| slowo[i+j+2] == 'u' || slowo[i+j+2] == 'y') return 1; if(slowo[i+j] != 'a' && slowo[i+j] != 'e' && slowo[i+j] != 'i' && slowo[i+j] != 'o'&& slowo[i+j] != 'u' && slowo[i+j] != 'y') if(slowo[i+j+1] != 'a' && slowo[i+j+1] != 'e' && slowo[i+j+1] != 'i' && slowo[i+j+1] != 'o'&& slowo[i+j+1] != 'u' && slowo[i+j+1] != 'y') if(slowo[i+j+2] != 'a' && slowo[i+j+2] != 'e' && slowo[i+j+2] != 'i' && slowo[i+j+2] != 'o'&& slowo[i+j+2] != 'u' && slowo[i+j+2] != 'y') return 1; } return 0; } */ int main() { string slowo; cin>>slowo; //cout<<slowo<<"\n"; long long n = slowo.size(); //long long wynik = 0; /* for(int i = 3; i <= n; ++i) { for(int j = 0; j < n - i + 1; ++j) { if(sprawdz(j, i)) { ++wynik; //cout<<"dl "<<i<<" pocz "<<j<<"\n"; } } } */ long long wynik2 = n*(n+1)/2; //cout<<wynik2<<"\n"; wynik2 -= n+(n-1); //cout<<wynik2<<"\n"; long long prev = 0; //int rodzaj_prev = 0; for(long long i = 1; i< n-1; ++i) { // cout<<i<<" "; if(slowo[i] == 'a' || slowo[i] == 'e' || slowo[i] == 'i' || slowo[i] == 'o'|| slowo[i] == 'u' || slowo[i] == 'y') if(slowo[i+1] == 'a' || slowo[i+1] == 'e' || slowo[i+1] == 'i' || slowo[i+1] == 'o'|| slowo[i+1] == 'u' || slowo[i+1] == 'y') if(slowo[i-1] == 'a' || slowo[i-1] == 'e' || slowo[i-1] == 'i' || slowo[i-1] == 'o'|| slowo[i-1] == 'u' || slowo[i-1] == 'y') { // cout<<"sam"; if(i - prev >= 3) wynik2-=(i-prev)*(i-prev-1)/2; // rodzaj_prev = 1; prev = i; } if(slowo[i] != 'a' && slowo[i] != 'e' && slowo[i] != 'i' && slowo[i] != 'o'&& slowo[i] != 'u' && slowo[i] != 'y') if(slowo[i+1] != 'a' && slowo[i+1] != 'e' && slowo[i+1] != 'i' && slowo[i+1] != 'o'&& slowo[i+1] != 'u' && slowo[i+1] != 'y') if(slowo[i-1] != 'a' && slowo[i-1] != 'e' && slowo[i-1] != 'i' && slowo[i-1] != 'o'&& slowo[i-1] != 'u' && slowo[i-1] != 'y') { // cout<<"spo"; if(i - prev >= 3) wynik2-=(i-prev-1)*(i-prev)/2; // rodzaj_prev = -1; prev = i; } // cout<<wynik2<<"\n"; } //cout<<prev<<"p\n"; //cout<<(n - prev - 2) * (n - prev - 1)/2<<"\n"; if(prev < n - 2) { wynik2 -= (n - prev - 2) * (n - prev - 1)/2; } cout <<wynik2<<"\n"; }
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #include<iostream> #include<string> #include<vector> using namespace std; /* bool sprawdz(int i, int k) { //cout<<i<<" "<<k<<"\n"; for(int j = 0; j < k-2; ++j) { if(slowo[i+j] == 'a' || slowo[i+j] == 'e' || slowo[i+j] == 'i' || slowo[i+j] == 'o'|| slowo[i+j] == 'u' || slowo[i+j] == 'y') if(slowo[i+j+1] == 'a' || slowo[i+j+1] == 'e' || slowo[i+j+1] == 'i' || slowo[i+j+1] == 'o'|| slowo[i+j+1] == 'u' || slowo[i+j+1] == 'y') if(slowo[i+j+2] == 'a' || slowo[i+j+2] == 'e' || slowo[i+j+2] == 'i' || slowo[i+j+2] == 'o'|| slowo[i+j+2] == 'u' || slowo[i+j+2] == 'y') return 1; if(slowo[i+j] != 'a' && slowo[i+j] != 'e' && slowo[i+j] != 'i' && slowo[i+j] != 'o'&& slowo[i+j] != 'u' && slowo[i+j] != 'y') if(slowo[i+j+1] != 'a' && slowo[i+j+1] != 'e' && slowo[i+j+1] != 'i' && slowo[i+j+1] != 'o'&& slowo[i+j+1] != 'u' && slowo[i+j+1] != 'y') if(slowo[i+j+2] != 'a' && slowo[i+j+2] != 'e' && slowo[i+j+2] != 'i' && slowo[i+j+2] != 'o'&& slowo[i+j+2] != 'u' && slowo[i+j+2] != 'y') return 1; } return 0; } */ int main() { string slowo; cin>>slowo; //cout<<slowo<<"\n"; long long n = slowo.size(); //long long wynik = 0; /* for(int i = 3; i <= n; ++i) { for(int j = 0; j < n - i + 1; ++j) { if(sprawdz(j, i)) { ++wynik; //cout<<"dl "<<i<<" pocz "<<j<<"\n"; } } } */ long long wynik2 = n*(n+1)/2; //cout<<wynik2<<"\n"; wynik2 -= n+(n-1); //cout<<wynik2<<"\n"; long long prev = 0; //int rodzaj_prev = 0; for(long long i = 1; i< n-1; ++i) { // cout<<i<<" "; if(slowo[i] == 'a' || slowo[i] == 'e' || slowo[i] == 'i' || slowo[i] == 'o'|| slowo[i] == 'u' || slowo[i] == 'y') if(slowo[i+1] == 'a' || slowo[i+1] == 'e' || slowo[i+1] == 'i' || slowo[i+1] == 'o'|| slowo[i+1] == 'u' || slowo[i+1] == 'y') if(slowo[i-1] == 'a' || slowo[i-1] == 'e' || slowo[i-1] == 'i' || slowo[i-1] == 'o'|| slowo[i-1] == 'u' || slowo[i-1] == 'y') { // cout<<"sam"; if(i - prev >= 3) wynik2-=(i-prev)*(i-prev-1)/2; // rodzaj_prev = 1; prev = i; } if(slowo[i] != 'a' && slowo[i] != 'e' && slowo[i] != 'i' && slowo[i] != 'o'&& slowo[i] != 'u' && slowo[i] != 'y') if(slowo[i+1] != 'a' && slowo[i+1] != 'e' && slowo[i+1] != 'i' && slowo[i+1] != 'o'&& slowo[i+1] != 'u' && slowo[i+1] != 'y') if(slowo[i-1] != 'a' && slowo[i-1] != 'e' && slowo[i-1] != 'i' && slowo[i-1] != 'o'&& slowo[i-1] != 'u' && slowo[i-1] != 'y') { // cout<<"spo"; if(i - prev >= 3) wynik2-=(i-prev-1)*(i-prev)/2; // rodzaj_prev = -1; prev = i; } // cout<<wynik2<<"\n"; } //cout<<prev<<"p\n"; //cout<<(n - prev - 2) * (n - prev - 1)/2<<"\n"; if(prev < n - 2) { wynik2 -= (n - prev - 2) * (n - prev - 1)/2; } cout <<wynik2<<"\n"; } |