Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <string>
- using namespace std;
- int main()
- {
- std::string word;
- std::getline(cin,word);
- int word_sz = word.size()-1;
- vector<int> Mask;
- vector<int> Counts;
- for(int i = word_sz; i > 0; i--){
- Mask.push_back(i);
- Counts.push_back(i+1);
- }
- Counts.emplace_back(1);
- int mask_sz = Mask.size();
- int disp = 0;
- for(int i = 1; i < word_sz; i++)
- {
- int CTR = 0;
- for(int k = disp; k < mask_sz; k++){
- Counts[i+CTR] += Mask[k];
- CTR++;
- }
- disp++;
- }
- Counts[Counts.size()-1]++;
- map<char,int> Freq;
- for(register int i = 0; i < word_sz+1; i++)
- Freq[word[i]] += Counts[i];
- for(auto &I : Freq)
- cout << I.first << ": " << I.second << endl;
- /*std::string Buf;
- for(auto K = Freq.cbegin(); K != Freq.cend(); K++){
- Buf += (K->first + ": " + to_string(K->second) + '\n');
- }*/
- /*string Dec = "";
- int ctr = word_sz;
- for(int x = 0; x < word_sz; x++)
- {
- for(int y = x; y < ctr; y++){
- cout << Dec << word.substr(x,y) << " ::: X,Y = " << x << " " << y << endl;
- }
- Dec+=" ";
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement