-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCyclic_shifts.cpp
More file actions
46 lines (44 loc) · 880 Bytes
/
Copy pathCyclic_shifts.cpp
File metadata and controls
46 lines (44 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* @Date : 2020-04-24 07:05:57
* @Author : Abhimanyu Kumar Maurya (aerma7309@gmail.com)
*/
#include <bits/stdc++.h>
using namespace std;
bool ib = ios_base::sync_with_stdio(0);
bool it = cin.tie(0);
int main()
{
unsigned short i, mask;
int t, m;
cin >> t;
char c;
bool bit;
while (t--)
{
cin >> i >> m >> c;
if (c == 'R')
{
while (m--)
{
bit = i & 1;
i >>= 1;
mask = 1 << 15;
mask = ~mask;
i &= mask;
i |= (bit << 15);
}
cout << i << '\n';
}
else
{
while (m--)
{
bit = (i >> 15) & 1;
i <<= 1;
i += bit;
}
cout << i << '\n';
}
}
return 0;
}