#include <iostream> using namespace std; bool sp(char c){ switch (c){ case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return false; break; default: return true; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); char c; int64_t start=0; int64_t it=0; int acc=0; int64_t sum=0; while(cin.get(c) && isalpha(c)) { if (sp(c)) acc= (acc>=0)?acc+1:1; else acc= (acc<=0)?acc-1:-1; if (acc>=3 || acc <=-3) start = it-1; sum += it-start+1; it++; } cout<<(it*(it+1))/2-sum<<endl; 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 | #include <iostream> using namespace std; bool sp(char c){ switch (c){ case 'a': case 'e': case 'i': case 'o': case 'u': case 'y': return false; break; default: return true; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); char c; int64_t start=0; int64_t it=0; int acc=0; int64_t sum=0; while(cin.get(c) && isalpha(c)) { if (sp(c)) acc= (acc>=0)?acc+1:1; else acc= (acc<=0)?acc-1:-1; if (acc>=3 || acc <=-3) start = it-1; sum += it-start+1; it++; } cout<<(it*(it+1))/2-sum<<endl; return 0; } |