#include <iostream> using namespace std; string pol=""; bool isSam (char c) { switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return true; } return false; } bool have (string str) { char f, s, t; f = str[0]; s = str[1]; t = str[2]; if ((isSam(f)==isSam(s))&&(isSam(s)==isSam(t))) return true; for (int i = 3; i<str.length(); i++) { f=s; s=t; t=str[i]; if ((isSam(f)==isSam(s))&&(isSam(s)==isSam(t))) return true; } return false;; } long howMany () { long counter = 0; for (long i = 0; i<pol.length()-2; i++) { for (long j = 3; j<= pol.length()-i; j++) { if (have(pol.substr(i, j))) { counter++; } } } return counter; } int main() { cin >> pol; cout << howMany(); 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 | #include <iostream> using namespace std; string pol=""; bool isSam (char c) { switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return true; } return false; } bool have (string str) { char f, s, t; f = str[0]; s = str[1]; t = str[2]; if ((isSam(f)==isSam(s))&&(isSam(s)==isSam(t))) return true; for (int i = 3; i<str.length(); i++) { f=s; s=t; t=str[i]; if ((isSam(f)==isSam(s))&&(isSam(s)==isSam(t))) return true; } return false;; } long howMany () { long counter = 0; for (long i = 0; i<pol.length()-2; i++) { for (long j = 3; j<= pol.length()-i; j++) { if (have(pol.substr(i, j))) { counter++; } } } return counter; } int main() { cin >> pol; cout << howMany(); return 0; } |