Advertisement
Guest User

Untitled

a guest
Oct 11th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1.  
  2. #include <vector>
  3. #include <cmath>
  4. #include <string.h>
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <string>
  8. using namespace std;
  9. long long factorial(long long n)
  10. {
  11. if (n == 0) {
  12. return 1;
  13. }
  14. return n * factorial(n - 1);
  15. }
  16. int main()
  17. {
  18. long long num = 0, same = 1;
  19. string s;
  20. cin >> s;
  21. vector <int> a(26);
  22. for (int i = 0; i < s.size(); ++i) {
  23. num = s[i];
  24. a[num - 97]++;
  25. }
  26. for (int i = 0; i < 26; ++i) {
  27. if (a[i] != 0) {
  28. same *= factorial(a[i]);
  29. }
  30. }
  31. cout << factorial(s.size()) / same;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement