#include <iostream> #include <string> using namespace std; static void countHardExp(string str) { long long count = 0; long long n = str.size(); long long prev = 0; for (long long i = 0; i < n - 2; i++) { if ((!(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'y') && !(str[i+1] == 'a' || str[i+1] == 'e' || str[i+1] == 'i' || str[i+1] == 'o' || str[i+1] == 'u' || str[i+1] == 'y') && !(str[i+2] == 'a' || str[i+2] == 'e' || str[i+2] == 'i' || str[i+2] == 'o' || str[i+2] == 'u' || str[i+2] == 'y')) || (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'y') && (str[i+1] == 'a' || str[i+1] == 'e' || str[i+1] == 'i' || str[i+1] == 'o' || str[i+1] == 'u' || str[i+1] == 'y') && (str[i+2] == 'a' || str[i+2] == 'e' || str[i+2] == 'i' || str[i+2] == 'o' || str[i+2] == 'u' || str[i+2] == 'y')) { count += (1 + (i-prev) + (n - (i + 3)) + ((i-prev) * (n - (i + 3)))); prev = i + 1; } } cout << count; } int main(int argc, char**argv) { string str; getline(cin, str); countHardExp(str); 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 | #include <iostream> #include <string> using namespace std; static void countHardExp(string str) { long long count = 0; long long n = str.size(); long long prev = 0; for (long long i = 0; i < n - 2; i++) { if ((!(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'y') && !(str[i+1] == 'a' || str[i+1] == 'e' || str[i+1] == 'i' || str[i+1] == 'o' || str[i+1] == 'u' || str[i+1] == 'y') && !(str[i+2] == 'a' || str[i+2] == 'e' || str[i+2] == 'i' || str[i+2] == 'o' || str[i+2] == 'u' || str[i+2] == 'y')) || (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'y') && (str[i+1] == 'a' || str[i+1] == 'e' || str[i+1] == 'i' || str[i+1] == 'o' || str[i+1] == 'u' || str[i+1] == 'y') && (str[i+2] == 'a' || str[i+2] == 'e' || str[i+2] == 'i' || str[i+2] == 'o' || str[i+2] == 'u' || str[i+2] == 'y')) { count += (1 + (i-prev) + (n - (i + 3)) + ((i-prev) * (n - (i + 3)))); prev = i + 1; } } cout << count; } int main(int argc, char**argv) { string str; getline(cin, str); countHardExp(str); return 0; } |