daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top