0858.cpp (199B)
1 class Solution { 2 public: 3 int mirrorReflection(int p, int q) { 4 while (p % 2 == 0 && q % 2 == 0) 5 p >>= 1, q >>= 1; 6 if (p & 1) return q & 1; 7 return 2; 8 } 9 };