#include <stdio.h> #include <cctype> bool samogloska(char x) { if( x == 'a' || x == 'e' || x == 'y' || x == 'o' || x == 'i' || x == 'u' ) { return true; } return false; } int main( ) { //int lastDiff[200000] = {}; //int start[200000] = {}; //int i; //for(i = 0 ; i < 200000; i++) { // lastDiff[i] = 0; // start[i] = 0; //} char ch2 = ' '; char ch1 = ' '; char ch = 'a'; int i = 0; int last = -1; int n = 0; unsigned long long res = 0; while (isalpha(ch)) { scanf("%c", &ch); if (isalpha(ch)) { //printf( "%c%c%c\n", ch2, ch1, ch); if (n >= 2) { if (samogloska(ch2) == samogloska(ch1) && samogloska(ch1) == samogloska(ch)) { if (last != -1) { //printf( "b - %d - %d\n", last, n); res += (last - 2 + 1) * (n - last); } last = n; } } ch2 = ch1; ch1 = ch; n++; } } if (last != n && last != -1) { //printf( "%d - %d\n", last, n); res += (last - 2 + 1) * (n - last); } printf( "%lld\n", res); 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 | #include <stdio.h> #include <cctype> bool samogloska(char x) { if( x == 'a' || x == 'e' || x == 'y' || x == 'o' || x == 'i' || x == 'u' ) { return true; } return false; } int main( ) { //int lastDiff[200000] = {}; //int start[200000] = {}; //int i; //for(i = 0 ; i < 200000; i++) { // lastDiff[i] = 0; // start[i] = 0; //} char ch2 = ' '; char ch1 = ' '; char ch = 'a'; int i = 0; int last = -1; int n = 0; unsigned long long res = 0; while (isalpha(ch)) { scanf("%c", &ch); if (isalpha(ch)) { //printf( "%c%c%c\n", ch2, ch1, ch); if (n >= 2) { if (samogloska(ch2) == samogloska(ch1) && samogloska(ch1) == samogloska(ch)) { if (last != -1) { //printf( "b - %d - %d\n", last, n); res += (last - 2 + 1) * (n - last); } last = n; } } ch2 = ch1; ch1 = ch; n++; } } if (last != n && last != -1) { //printf( "%d - %d\n", last, n); res += (last - 2 + 1) * (n - last); } printf( "%lld\n", res); return 0; } |