fork download
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. long long fact (int n) {
  6. return (n == 1 ? n : n * fact (n - 1));
  7. }
  8.  
  9. int main() {
  10. string s;
  11. map <char, int> m;
  12. cin >> s;
  13. int l = s.size(), count = 1;
  14. for (int i = 0; i < l; i++)
  15. m[s[i]] = (m[s[i]] ? ++m[s[i]] : 1);
  16. for (auto it = m.begin(); it != m.end(); it++)
  17. if (it -> second > 1) count *= fact (it -> second);
  18. cout << fact(l) / count;
  19. return 0;
  20. }
Success #stdin #stdout 0s 15240KB
stdin
AABBBCCC
stdout
560