#include <bits/stdc++.h> using namespace std; bool sam(char x){ return (x=='a' || x=='e' || x=='o' || x=='i' || x=='u' || x=='y'); } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; long long wynik = 0; int last = -1; for(int i = 2; i < s.size(); i++){ if(sam(s[i-2])==sam(s[i-1]) && sam(s[i-1]) == sam(s[i])) last = i-2; wynik += (long long)(last + 1); } cout << wynik << "\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 | #include <bits/stdc++.h> using namespace std; bool sam(char x){ return (x=='a' || x=='e' || x=='o' || x=='i' || x=='u' || x=='y'); } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; long long wynik = 0; int last = -1; for(int i = 2; i < s.size(); i++){ if(sam(s[i-2])==sam(s[i-1]) && sam(s[i-1]) == sam(s[i])) last = i-2; wynik += (long long)(last + 1); } cout << wynik << "\n"; return 0; } |