Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <algorithm>
- using namespace std;
- int ap[10];
- int main()
- {
- char sir[50];
- cin >> sir;
- long long cate = 0;
- if(strlen(sir) == 1)
- {
- cout << 1;
- return 0;
- }
- for(int i = 0; i < strlen(sir); i++)
- {
- int k = sir[i] - '0';
- ap[k] += 1;
- // cout << k <<" ";
- }
- int shit = 0;
- for(int i = 0; i < 10; i++)
- {
- if(ap[i] % 2 == 1)
- {
- shit += 1;
- ap[i] -= 1;
- }
- if(shit >= 2)
- {
- cout << 0;
- return 0;
- }
- }
- string cacat;
- char aux[50];
- int k = 0;
- for(int i = 0; i < 10; i++)
- {
- if(ap[i] != 0 && ap[i] % 2 == 0)
- {
- ap[i] /= 2;
- char ll = (i + '0');
- while(ap[i])
- {
- cacat += ll;
- ap[i] --;
- }
- }
- }
- for(int i = 0; i <= cacat.length(); i++)
- aux[i] = cacat[i];
- aux[strlen(aux)] = '\0';
- do
- {
- if(aux[0] != '0')
- cate += 1;
- } while(next_permutation(aux,aux+strlen(aux)));
- cout << cate;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement