mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 15:01:40 +08:00
国外版
This commit is contained in:
30
算法题(国外版)/mirror-reflection.html
Normal file
30
算法题(国外版)/mirror-reflection.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<p>There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered <code>0</code>, <code>1</code>, and <code>2</code>.</p>
|
||||
|
||||
<p>The square room has walls of length <code>p</code> and a laser ray from the southwest corner first meets the east wall at a distance <code>q</code> from the <code>0<sup>th</sup></code> receptor.</p>
|
||||
|
||||
<p>Given the two integers <code>p</code> and <code>q</code>, return <em>the number of the receptor that the ray meets first</em>.</p>
|
||||
|
||||
<p>The test cases are guaranteed so that the ray will meet a receptor eventually.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/06/18/reflection.png" style="width: 218px; height: 217px;" />
|
||||
<pre>
|
||||
<strong>Input:</strong> p = 2, q = 1
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> The ray meets receptor 2 the first time it gets reflected back to the left wall.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> p = 3, q = 1
|
||||
<strong>Output:</strong> 1
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= q <= p <= 1000</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user