#include <iostream> #include <cmath> #include<string> using namespace std; int main() { string s; string pom=""; cin>>s; int dl=s.size(); int wyn=0; int a=0; int b=0; int c=0; int p=0; for (int k=0;k<dl;k++){ for (int i =p; i<dl; i++){ //for (int j=0;j<pom.size();j++){ if (s[i]=='a' )a++; if (s[i]=='b' )b++; if (s[i]=='c' )c++; //} if (a==0&&b==0) wyn++; if (c==0&&b==0) wyn++; if (a==0&&c==0) wyn++; if (a==b&&c==0) wyn++; if (a==c&&b==0) wyn++; if (c==b&&a==0) wyn++; if (a==b&&b==c) wyn++; //cout<<a<<" "<<b<<" "<<c<<" "<<wyn<<endl; } a=0; b=0; c=0; p++; } cout<<wyn; 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 | #include <iostream> #include <cmath> #include<string> using namespace std; int main() { string s; string pom=""; cin>>s; int dl=s.size(); int wyn=0; int a=0; int b=0; int c=0; int p=0; for (int k=0;k<dl;k++){ for (int i =p; i<dl; i++){ //for (int j=0;j<pom.size();j++){ if (s[i]=='a' )a++; if (s[i]=='b' )b++; if (s[i]=='c' )c++; //} if (a==0&&b==0) wyn++; if (c==0&&b==0) wyn++; if (a==0&&c==0) wyn++; if (a==b&&c==0) wyn++; if (a==c&&b==0) wyn++; if (c==b&&a==0) wyn++; if (a==b&&b==c) wyn++; //cout<<a<<" "<<b<<" "<<c<<" "<<wyn<<endl; } a=0; b=0; c=0; p++; } cout<<wyn; return 0; } |