#include<cstdio> inline int vowel(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y') { return 1; } return 0; } int main() { char c; int l1 = -1; int l2 = -1; int l3 = -1; int last = -1; int x; int i = 0; long long int sum = 0; while (1) { ++i; x = scanf("%c", &c); if (x <= 0) { break; } if (c < 'a' or c > 'z') { break; } l3 = l2; l2 = l1; l1 = vowel(c); if ((l1 == l2) && (l2 == l3)) { last = i - 2; } if (last > 0) { sum += last; } } printf("%lld\n", sum); 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 | #include<cstdio> inline int vowel(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y') { return 1; } return 0; } int main() { char c; int l1 = -1; int l2 = -1; int l3 = -1; int last = -1; int x; int i = 0; long long int sum = 0; while (1) { ++i; x = scanf("%c", &c); if (x <= 0) { break; } if (c < 'a' or c > 'z') { break; } l3 = l2; l2 = l1; l1 = vowel(c); if ((l1 == l2) && (l2 == l3)) { last = i - 2; } if (last > 0) { sum += last; } } printf("%lld\n", sum); return 0; } |