fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define dd double
  5. #define ld long double
  6. #define ull unsigned long long
  7. #define yes cout << "YES\n"
  8. #define no cout << "NO\n"
  9. #define el "\n"
  10. #define o_o ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  11. #define fix(x) cout << fixed << setprecision(x)
  12. #define all(v) v.begin(),v.end()
  13. #define dpp(v,val) memset(v,val,sizeof(v))
  14. #define mod 1e9+7
  15. const int N = 1e5 + 5;
  16. int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } // log(n) __gcd(a,b)
  17. int n,k;
  18. vector<string>ans;
  19. void rec(int i,string s)
  20. {
  21. // ans.push_back(s);
  22. if(i==n+1) {
  23. cout<<s[k-1]<<el;
  24. return;
  25. }
  26. string v=s;
  27. s.clear();
  28. for(int i=0;i<v.length();i++)
  29. {
  30. if(v[i]=='0')
  31. s+="01";
  32. else
  33. s+="10";
  34. }
  35. rec(i+1,s);
  36. }
  37. void HereWeGoAgain()
  38. {
  39. cin>>n>>k;
  40. string s="0";
  41. rec(1,s);
  42. }
  43. int32_t main()
  44. {
  45. o_o
  46. int t=1;
  47. cin>>t;
  48. for(int i=1;i<=t;i++)
  49. {
  50. HereWeGoAgain();
  51. }
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout