#include <string.h>
#include <stdio.h>
static long long int iCnt, iLastStart, iLen;
static char sBuff[200002];
static inline bool IsVowel(char c)
{
switch (c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'y':
return true;
default:
return false;
}
}
int main(int argc, char * argv[])
{
scanf("%s", sBuff);
iLen = strlen(sBuff);
iCnt = 0;
bool fFound = false;
for (int i = 2; i < iLen; ++i)
{
if (IsVowel(sBuff[i]))
{
if (IsVowel(sBuff[i - 1]) && IsVowel(sBuff[i - 2]))
{
fFound = true;
iLastStart = i - 2;
}
}
else
{
if (!IsVowel(sBuff[i - 1]) && !IsVowel(sBuff[i - 2]))
{
fFound = true;
iLastStart = i - 2;
}
}
if (fFound)
iCnt += (iLastStart + 1);
}
printf("%lld", iCnt);
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 64 | #include <string.h> #include <stdio.h> static long long int iCnt, iLastStart, iLen; static char sBuff[200002]; static inline bool IsVowel(char c) { switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return true; default: return false; } } int main(int argc, char * argv[]) { scanf("%s", sBuff); iLen = strlen(sBuff); iCnt = 0; bool fFound = false; for (int i = 2; i < iLen; ++i) { if (IsVowel(sBuff[i])) { if (IsVowel(sBuff[i - 1]) && IsVowel(sBuff[i - 2])) { fFound = true; iLastStart = i - 2; } } else { if (!IsVowel(sBuff[i - 1]) && !IsVowel(sBuff[i - 2])) { fFound = true; iLastStart = i - 2; } } if (fFound) iCnt += (iLastStart + 1); } printf("%lld", iCnt); return 0; } |
English