You are given a number \(N\) represented as a binary representation of \(X = 16\) bits. You are also given a number \(m\) and a character \(c\ (L\ or\ R) \).
Determine a number \(M\) that is generated after cyclically shifting the binary representation of \(N\) by \(m\) positions either left if \(c = L\) or right is \(c = R\).
Input format
- The first line contains an integer \(T\) representing the number of queries.
- The next \(T\) lines contain \(N\ m\ c\) as mentioned in the problem statement.
Output format
Print \(T\) integers in a separate line representing the answer to each query.
Constraints
\(1 \le T \le 1e4\\
1 \le N \le 65535\\
1 \le m \le 15\)
For first case : N in binary is 0001 1110 1100 1001 and shifting it left by 5 position, it becomes 1101 1001 0010 0011 which in decimal system is 55587
For second case : N in binary is 0001 1110 1100 1001 and shifted 3 position to right it becomes 0010 0011 1101 1001 which in decimal system is 9177
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor