#include <iostream> #include <string> using namespace std; string s; char sam[] = {'a','e','i','o','u','y'}; bool issam(char srak){ for(int i=0; i<6; i++){ if(srak==sam[i]) return true; } return false; } int main(){ ios_base::sync_with_stdio(0); cin>>s; long long n = s.size(); bool lastSam = false; bool lastSpol = false; int ile = 0; long long wynik = 0; int l = 0; for(int i=0; i<s.size(); i++){ char t = s[i]; if(issam(t)){ if(lastSam) ile++; else{ ile = 1; } lastSam = true; lastSpol = false; } else{ if(lastSpol) ile++; else{ ile = 1; } lastSam = false; lastSpol = true; } //printf("i: %d ile: %d\n",i,ile); if(ile>=3){ l = i -1; } wynik+=(long long)(i-l+1LL); //printf("i: %d wynik: %d\n",i,wynik); } cout<<(n*(n+1LL))/2LL-wynik<<endl; }
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 | #include <iostream> #include <string> using namespace std; string s; char sam[] = {'a','e','i','o','u','y'}; bool issam(char srak){ for(int i=0; i<6; i++){ if(srak==sam[i]) return true; } return false; } int main(){ ios_base::sync_with_stdio(0); cin>>s; long long n = s.size(); bool lastSam = false; bool lastSpol = false; int ile = 0; long long wynik = 0; int l = 0; for(int i=0; i<s.size(); i++){ char t = s[i]; if(issam(t)){ if(lastSam) ile++; else{ ile = 1; } lastSam = true; lastSpol = false; } else{ if(lastSpol) ile++; else{ ile = 1; } lastSam = false; lastSpol = true; } //printf("i: %d ile: %d\n",i,ile); if(ile>=3){ l = i -1; } wynik+=(long long)(i-l+1LL); //printf("i: %d wynik: %d\n",i,wynik); } cout<<(n*(n+1LL))/2LL-wynik<<endl; } |