fork(5) download
  1. /*
  2. * The way if it's all predetermined
  3. * And the way i should go all my life
  4. * I swear to go wherever will be
  5. * 'Cause there'll be something to see and to find
  6. */
  7. #include "bits/stdc++.h"
  8. #define ll long long
  9. using namespace std;
  10. #define check(x) cerr << #x << ": " << x << endl;
  11. #define print(ans) cout << ans << endl;
  12. int main(){
  13. ios_base::sync_with_stdio(false);
  14. cin.tie(NULL);
  15. int t;
  16. cin >> t;
  17. while(t--){
  18. int n;
  19. string s;
  20. cin >> n >> s;
  21. int m = 1<<n;
  22. map < deque <char> , int > f;
  23. for(int i = 1;i<m;i++){
  24. std::deque<char> k;
  25. for(int j=0;j<n;j++){
  26. int x = 1<<j;
  27. if(x&i)
  28. k.push_back(s[j]);
  29. }
  30. while(k.size() > 1 and k.front() == '0')
  31. k.pop_front();
  32. f[k]++;
  33. }
  34. cout << f.size();
  35. }
  36. cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << "\n";
  37. return 0;
  38. }
Success #stdin #stdout #stderr 0.05s 5632KB
stdin
1
17 
10110011011011101
stdout
2005
stderr
time taken : 0.045379 secs