Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long I64;
  6.  
  7. I64 last(I64 n, bool inc)
  8. {
  9. if (n == 1)
  10. return 0;
  11. I64 recurs = last((n - inc) / 2, inc ^ (n & 1LL));
  12. return 2 * recurs + !inc;
  13. }
  14.  
  15. void solve()
  16. {
  17. I64 n, k;
  18. cin >> n >> k;
  19. I64 ans = last(n, 0);
  20. ans = (ans + k - 1) % n + 1;
  21. cout << ans << ((n & 1LL) ? " Light\n" : " L\n");
  22. }
  23.  
  24. int main()
  25. {
  26. ios_base::sync_with_stdio(0);
  27. cin.tie(0);
  28. cout.tie(0);
  29.  
  30. int t = 1;
  31. cin >> t; /// comment
  32. while (t--) {
  33. solve();
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement