#include <bits/stdc++.h> using namespace std; string text; string samogloski = "eyuioa"; bool samogloska(char a) { for(int i =0; i<samogloski.length(); ++i) if(samogloski[i] == a) return true; return false; } bool trudne(int i) { if(samogloska(text[i-2])) { if(samogloska(text[i-1]) && samogloska(text[i])) return true; } else { if(!samogloska(text[i-1]) && !samogloska(text[i])) return true; } return false; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(0); cin>>text; int last_difficult; int i; for(i = 2; i < text.length(); ++i) { if(trudne(i)) { last_difficult = i; break; } } long long result = 0; for(; i< text.length(); ++i) { if(trudne(i)) { //cout<<i<<" "<<text[i-2]<<text[i-1]<<text[i]<<"\n"; last_difficult = i; } result += last_difficult - 1; } cout<<result<<"\n"; 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 56 57 58 59 60 61 62 63 64 65 66 | #include <bits/stdc++.h> using namespace std; string text; string samogloski = "eyuioa"; bool samogloska(char a) { for(int i =0; i<samogloski.length(); ++i) if(samogloski[i] == a) return true; return false; } bool trudne(int i) { if(samogloska(text[i-2])) { if(samogloska(text[i-1]) && samogloska(text[i])) return true; } else { if(!samogloska(text[i-1]) && !samogloska(text[i])) return true; } return false; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(0); cin>>text; int last_difficult; int i; for(i = 2; i < text.length(); ++i) { if(trudne(i)) { last_difficult = i; break; } } long long result = 0; for(; i< text.length(); ++i) { if(trudne(i)) { //cout<<i<<" "<<text[i-2]<<text[i-1]<<text[i]<<"\n"; last_difficult = i; } result += last_difficult - 1; } cout<<result<<"\n"; return 0; } |