#include <iostream>
#include <string>
using namespace std;
using LL = long long;
int main()
{
string str;
cin >> str;
LL res = 0;
int last = -1;
int sa = 0;
int sp = 0;
for (int i = 0; i < str.length(); ++i)
{
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'y')
{
sa++;
sp = 0;
}
else
{
sp++;
sa = 0;
}
if (sa >= 3 || sp >= 3)
{
LL t = i - last - 2;
res += t * (str.length() - i);
last = i - 2;
}
}
cout << 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 | #include <iostream> #include <string> using namespace std; using LL = long long; int main() { string str; cin >> str; LL res = 0; int last = -1; int sa = 0; int sp = 0; for (int i = 0; i < str.length(); ++i) { if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'y') { sa++; sp = 0; } else { sp++; sa = 0; } if (sa >= 3 || sp >= 3) { LL t = i - last - 2; res += t * (str.length() - i); last = i - 2; } } cout << res; return 0; } |
English