fork(1) download
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. int t, n, f[26], cnt;
  5. ll fact[21], ans;
  6. char s[21];
  7. int main() {
  8. fact[0] = 1;
  9. for (int i = 1; i <= 20; ++i)
  10. fact[i] = fact[i - 1] * i;
  11. scanf("%d", &t);
  12. while (t--) {
  13. memset(f, 0, sizeof f);
  14. scanf("%d%s", &n, s);
  15. for (int i = 0; i < n; ++i)
  16. ++f[s[i] - 'a'];
  17. cnt = 0;
  18. for (int i = 0; i < 26; ++i)
  19. if (f[i] & 1) ++cnt;
  20. if (cnt > 1) puts("0");
  21. else {
  22. for (int i = 0; i < 26; ++i)
  23. f[i] /= 2;
  24. ans = fact[n / 2];
  25. for (int i = 0; i < 26; ++i)
  26. ans /= fact[f[i]];
  27. printf("%lld\n", ans);
  28. }
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty