//Jan Sosnowski zadanie pol #include<iostream> #include<string> #include<vector> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int n = s.size(); long long wyn = 0; vector < bool > lit; for(int i = 0; i<n;i++){ if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y'){ lit.push_back(1); } else{ lit.push_back(0); } } int pocz = 0; for(int i = 0;i<n-2;i++){ if(lit[i] == lit[i+1] && lit[i] == lit[i+2]){ wyn += (i+1-pocz)*(n-i-2); pocz = i+1; } } cout << wyn; }
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 | //Jan Sosnowski zadanie pol #include<iostream> #include<string> #include<vector> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int n = s.size(); long long wyn = 0; vector < bool > lit; for(int i = 0; i<n;i++){ if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y'){ lit.push_back(1); } else{ lit.push_back(0); } } int pocz = 0; for(int i = 0;i<n-2;i++){ if(lit[i] == lit[i+1] && lit[i] == lit[i+2]){ wyn += (i+1-pocz)*(n-i-2); pocz = i+1; } } cout << wyn; } |