Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int ap[10];
  8.  
  9. int main()
  10. {
  11. char sir[50];
  12.  
  13.  
  14. cin >> sir;
  15.  
  16. long long cate = 0;
  17.  
  18. if(strlen(sir) == 1)
  19. {
  20. cout << 1;
  21. return 0;
  22. }
  23.  
  24. for(int i = 0; i < strlen(sir); i++)
  25. {
  26. int k = sir[i] - '0';
  27. ap[k] += 1;
  28. // cout << k <<" ";
  29. }
  30. int shit = 0;
  31.  
  32.  
  33. for(int i = 0; i < 10; i++)
  34. {
  35. if(ap[i] % 2 == 1)
  36. {
  37. shit += 1;
  38. ap[i] -= 1;
  39. }
  40. if(shit >= 2)
  41. {
  42. cout << 0;
  43. return 0;
  44. }
  45. }
  46. string cacat;
  47. char aux[50];
  48. int k = 0;
  49. for(int i = 0; i < 10; i++)
  50. {
  51. if(ap[i] != 0 && ap[i] % 2 == 0)
  52. {
  53. ap[i] /= 2;
  54. char ll = (i + '0');
  55. while(ap[i])
  56. {
  57. cacat += ll;
  58. ap[i] --;
  59. }
  60. }
  61. }
  62.  
  63.  
  64. for(int i = 0; i <= cacat.length(); i++)
  65. aux[i] = cacat[i];
  66.  
  67.  
  68. aux[strlen(aux)] = '\0';
  69. do
  70. {
  71. if(aux[0] != '0')
  72. cate += 1;
  73.  
  74.  
  75. } while(next_permutation(aux,aux+strlen(aux)));
  76. cout << cate;
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement