fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int k;
  6. cin >> k;
  7.  
  8. while (k--) {
  9. int D, i;
  10. cin >> D >> i;
  11.  
  12.  
  13. if (i < 1 || i >= (1 << D)) {
  14. cout << "False" << endl;
  15. continue;
  16. }
  17.  
  18.  
  19. cout << "True" << endl;
  20. vector<char> path;
  21.  
  22. int node = i;
  23. while (node > 1) {
  24. if (node % 2 == 0) {
  25. path.push_back('L');
  26. } else {
  27. path.push_back('R');
  28. }
  29. node /= 2;
  30. }
  31.  
  32.  
  33. reverse(path.begin(), path.end());
  34. for (char c : path) {
  35. cout << c;
  36. }
  37. cout << endl;
  38. }
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
5
4 2
3 4
10 1
2 2
8 128
stdout
True
L
True
LL
True

True
L
True
LLLLLLL