#include <bits/stdc++.h> using namespace std; bool t[26]; #define LL long long int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin>>s; int ost = 0; int n = s.size(); t[0] = 1; t[4] = 1; t[8] = 1; t[14] = 1; t[20] = 1; t[24] = 1; LL w = 0; for(int i=0; i<n-2; i++) { int x = s[i] - 97; int y = s[i+1] - 97; int z = s[i+2] - 97; if(t[x]==t[y] && t[y]==t[z]) { LL a = i-ost+1; LL b = n-1-i-1; //cout<<a*b<<" * "<<a<<" "<<b<<endl; ost = i+1; w+=(a*b); } } cout<<w; }
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 | #include <bits/stdc++.h> using namespace std; bool t[26]; #define LL long long int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin>>s; int ost = 0; int n = s.size(); t[0] = 1; t[4] = 1; t[8] = 1; t[14] = 1; t[20] = 1; t[24] = 1; LL w = 0; for(int i=0; i<n-2; i++) { int x = s[i] - 97; int y = s[i+1] - 97; int z = s[i+2] - 97; if(t[x]==t[y] && t[y]==t[z]) { LL a = i-ost+1; LL b = n-1-i-1; //cout<<a*b<<" * "<<a<<" "<<b<<endl; ost = i+1; w+=(a*b); } } cout<<w; } |