#include <iostream> #include <algorithm> #include <string> using namespace std; char sam[6]={'a','e','i','o','u','y'}; bool glo(char a, char b, char c){ bool p,d,t; p=false; d=false; t=false; for(int i = 0; i<6; i++){ if(a==sam[i]){ p=true; } if(b==sam[i]){ d=true; } if(c==sam[i]){ t=true; } } if (p&&d&&t){ return true; } if(!(p||d||t)){ return true; } return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string word; cin >> word; bool byl = false; int indeks = -1; long long wynik = 0; for(int i = 0; i<word.length()-2; i++){ if(glo(word[i],word[i+1],word[i+2])){ if(!byl){ indeks=i+1; byl=true; wynik+=(i+1)*((word.length()-(i+2))); } else{ wynik+=((i+1)-indeks)*((word.length()-(i+2))); indeks=i+1; } } } cout << wynik << endl; return 0; }
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 | #include <iostream> #include <algorithm> #include <string> using namespace std; char sam[6]={'a','e','i','o','u','y'}; bool glo(char a, char b, char c){ bool p,d,t; p=false; d=false; t=false; for(int i = 0; i<6; i++){ if(a==sam[i]){ p=true; } if(b==sam[i]){ d=true; } if(c==sam[i]){ t=true; } } if (p&&d&&t){ return true; } if(!(p||d||t)){ return true; } return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string word; cin >> word; bool byl = false; int indeks = -1; long long wynik = 0; for(int i = 0; i<word.length()-2; i++){ if(glo(word[i],word[i+1],word[i+2])){ if(!byl){ indeks=i+1; byl=true; wynik+=(i+1)*((word.length()-(i+2))); } else{ wynik+=((i+1)-indeks)*((word.length()-(i+2))); indeks=i+1; } } } cout << wynik << endl; return 0; } |