Cyclic shifts
Practice
4 (87 votes)
Basic programming
Bit manipulation
C++
Problem
81% Success 10076 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
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\)
Submissions
Please login to view your submissions
Similar Problems
Points:10
9 votes
Tags:
Bit ManipulationBasics of Bit ManipulationBasic Programming
Points:10
80 votes
Tags:
Bit manipulationBit ManipulationBasics of Bit ManipulationBasic Programming
Points:10
46 votes
Tags:
Basic ProgrammingBit ManipulationBit manipulation
Editorial