#include <cstdio> char s[200005]; char v[256]; typedef long long Long64; Long64 f(char *s) { int i,n,sum = 0, prev = 1; Long64 result = 0; for (n=0; s[n]; ++n) { s[n] = v[s[n]]; } for (i=0; i<n; ++i) { sum += s[i]; if (i>=3) { sum -= s[i-3]; } if (i>=2) { if (sum == 0 || sum == 3) { result += Long64(i-prev) * Long64(n-i); prev = i; } } } return result; } int main() { v['a'] = v['e'] = v['i'] = v['o'] = v['u'] = v['y'] = 1; scanf("%s",s); printf("%lld",f(s)); 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 | #include <cstdio> char s[200005]; char v[256]; typedef long long Long64; Long64 f(char *s) { int i,n,sum = 0, prev = 1; Long64 result = 0; for (n=0; s[n]; ++n) { s[n] = v[s[n]]; } for (i=0; i<n; ++i) { sum += s[i]; if (i>=3) { sum -= s[i-3]; } if (i>=2) { if (sum == 0 || sum == 3) { result += Long64(i-prev) * Long64(n-i); prev = i; } } } return result; } int main() { v['a'] = v['e'] = v['i'] = v['o'] = v['u'] = v['y'] = 1; scanf("%s",s); printf("%lld",f(s)); return 0; } |