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 Arwa 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. //todo اى ويل بريبير ماى بيبرز تو بى ذا بيست ان زيس وورلد
  18. int n,k;
  19. vector<string>ans;
  20. void rec(int i,string s)
  21. {
  22. // ans.push_back(s);
  23. if(i==n+1) {
  24. cout<<s[k-1]<<el;
  25. return;
  26. }
  27. string v=s;
  28. s.clear();
  29. for(int i=0;i<v.length();i++)
  30. {
  31. if(v[i]=='0')
  32. s+="01";
  33. else
  34. s+="10";
  35. }
  36. rec(i+1,s);
  37. }
  38. void HereWeGoAgain()
  39. {
  40. cin>>n>>k;
  41. string s="0";
  42. rec(1,s);
  43. }
  44. int32_t main()
  45. {
  46. Arwa
  47. int t=1;
  48. cin>>t;
  49. for(int i=1;i<=t;i++)
  50. {
  51. HereWeGoAgain();
  52. }
  53. return 0;
  54. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout