Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<algorithm>
  4. #include<vector>
  5. using namespace std;
  6. string temp, b;
  7. int d=0, arr[52], a, total=0;
  8. vector<int> count;
  9. void how_many_different_letters(){
  10. for(int i=0; i<temp.size(); i++){
  11.     if(temp[i]!=temp[i+1])
  12.         d++;
  13. }
  14. }
  15. void turn_arr_to_zero(){
  16. for(int u=0; u<52; u++)
  17.             arr[u]=0;
  18. }
  19. void find_how_many_letters_of_each_type(){
  20.     for(int k=j; k<j+i; k++){
  21.             if(b[k]-'A'<32)
  22.                 arr[b[k]-'A']++;
  23.             else
  24.                 arr[b[k]-'A'-6]++;
  25.     }
  26. }
  27. void forming_count(){
  28.     for(int u=0; u<52; u++){
  29.         if(arr[u]!=0)
  30.         count.push_back(arr[u]);
  31.     }
  32. }
  33. void checking_if_letter_appear_an_equal_amount_of_times(){
  34.     if(count.size()==d){
  35.         int f=0;
  36.         for(int k=0; k<count.size(); k++){
  37.             if(count[k]!=count[k+1])
  38.                 f++;
  39.         }
  40.         if(f==0)
  41.             total++;
  42.     }
  43. }
  44. int main(){
  45. cin>>a;
  46. cin>>b;
  47. temp=b;
  48. sort(temp.begin(), temp.end());
  49. how_many_different_letters();
  50. //cout<<d<<endl;
  51. for(int i=1; i<=a; i++){
  52.     for(int j=0; j<=a-i; j++){
  53.         turn_arr_to_zero();
  54.         find_how_many_letters_of_each_type();
  55.         forming_count();
  56.         checking_if_letter_appear_an_equal_amount_of_times();
  57.     }
  58. }
  59. cout<<total;
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement