A square hall has mirrors on all four walls.
Receptors are fixed at three corners:
• 0 → northeast corner
• 1 → southeast corner
• 2 → northwest corner
A laser starts at the southwest corner and travels at a 45° angle upward.
The room’s side length is p.
The laser first hits the east wall at a vertical distance q from receptor 0.
Your task: Find which receptor number (0, 1, or 2) the laser touches first.
Input: p = 2, q = 1
Output: 2
Explanation:
The ray bounces and first meets the receptor at corner 2.
Input: p = 3, q = 1
Output: 1
Explanation:
After reflections, the ray reaches receptor 1 first.
Accepted:
Submission: