1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-20 01:56:57 +02:00
LeetCode/cpp/mirror-reflection.cpp
Matej Focko 2351dfd0ee
chore: unwrap one layer
Signed-off-by: Matej Focko <mfocko@redhat.com>
2023-12-12 14:36:00 +01:00

18 lines
310 B
C++

class Solution {
public:
int mirrorReflection(int p, int q)
{
auto lcm = p * q / std::gcd(p, q);
auto x = lcm / p;
auto y = lcm / q;
if (x % 2 == 0) {
return 0;
}
if (y % 2 == 0) {
return 2;
}
return 1;
}
};