#include <cstdio> #define MAX_SIZE 200002 char str[MAX_SIZE]; // a, e, i, o, u oraz y bool samogloski[255]; int strlen(char* pString) { if (pString == NULL) return 0; unsigned int Count = 0; while (*pString++) ++Count; return Count; } int main() { //freopen("ms337666_PA_polmax.in", "r", stdin); samogloski['a'] = true; samogloski['e'] = true; samogloski['i'] = true; samogloski['o'] = true; samogloski['u'] = true; samogloski['y'] = true; scanf("%s", str); int length = strlen(str); if (length < 3) { printf("0"); return 0; } long long int result = 0; int distanceFromBeginOfString; int distanceToTheEndOfString; int count = 0; for (int i = 0; i < length - 2; i++) { if ((samogloski[str[i]] && samogloski[str[i + 1]] && samogloski[str[i + 2]]) || (!samogloski[str[i]] && !samogloski[str[i + 1]] && !samogloski[str[i + 2]])) { distanceFromBeginOfString = i; distanceToTheEndOfString = length - 1 - (i + 2); result += 1 + distanceFromBeginOfString*(1 + distanceToTheEndOfString) + distanceToTheEndOfString; // == 1 + distanceFromBeginOfString + distanceFromBeginOfString * distanceToTheEndOfString + distanceToTheEndOfString } } //result -= iloraz; printf("%lld", result); 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 | #include <cstdio> #define MAX_SIZE 200002 char str[MAX_SIZE]; // a, e, i, o, u oraz y bool samogloski[255]; int strlen(char* pString) { if (pString == NULL) return 0; unsigned int Count = 0; while (*pString++) ++Count; return Count; } int main() { //freopen("ms337666_PA_polmax.in", "r", stdin); samogloski['a'] = true; samogloski['e'] = true; samogloski['i'] = true; samogloski['o'] = true; samogloski['u'] = true; samogloski['y'] = true; scanf("%s", str); int length = strlen(str); if (length < 3) { printf("0"); return 0; } long long int result = 0; int distanceFromBeginOfString; int distanceToTheEndOfString; int count = 0; for (int i = 0; i < length - 2; i++) { if ((samogloski[str[i]] && samogloski[str[i + 1]] && samogloski[str[i + 2]]) || (!samogloski[str[i]] && !samogloski[str[i + 1]] && !samogloski[str[i + 2]])) { distanceFromBeginOfString = i; distanceToTheEndOfString = length - 1 - (i + 2); result += 1 + distanceFromBeginOfString*(1 + distanceToTheEndOfString) + distanceToTheEndOfString; // == 1 + distanceFromBeginOfString + distanceFromBeginOfString * distanceToTheEndOfString + distanceToTheEndOfString } } //result -= iloraz; printf("%lld", result); return 0; } |