Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //{ Driver Code Starts
- #include<bits/stdc++.h>
- using namespace std;
- // } Driver Code Ends
- class Solution
- {
- public:
- vector <int> rotate (int n, int d)
- {
- d%=16;
- int left = ((n<<d) | (n>>(16-d))) & 65535;
- int right = (n>>d) | (n<<(16-d)) & 0xFFFF;
- return {left,right};
- }
- };
- //{ Driver Code Starts.
- int main()
- {
- int t; cin >> t;
- while (t--)
- {
- int n, d; cin >> n >> d;
- Solution ob;
- vector <int> res = ob.rotate (n, d);
- cout << res[0] << endl << res[1] << endl;
- }
- }
- // Contributed By: Pranay Bansal
- // } Driver Code Ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement