How to solve this problem using bitmask or bit manuplation ??
Problem Link :https://mirror.codeforces.com/problemset/problem/1097/B Editorial Link :https://mirror.codeforces.com/blog/entry/64310
I am not able to understand the editorial which says that clockwise rotation will be done if ith bit is set to 0 and vive versa ?? Can someone explain in detail ?
Every rotation can be represented as 0 — clockwise or 1 — counterclockwise. It means that if you have to do N rotations, than you can represent all possible ways of rotations by 2 ^ N bit strings. For example for N = 2 you have 4 states — 00, 01, 10, 11. Than just check each state (iterate throw bit string, if bit is 1 — add angle, else — substract) if angle is divisible by 360, you found solution.