1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/圆和矩形是否有重叠 [circle-and-rectangle-overlapping].html

41 lines
1.8 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给你一个以 <code>(radius, xCenter, yCenter)</code> 表示的圆和一个与坐标轴平行的矩形 <code>(x1, y1, x2, y2)</code> ,其中 <code>(x1, y1)</code> 是矩形左下角的坐标,而 <code>(x2, y2)</code> 是右上角的坐标。</p>
2022-03-27 20:37:52 +08:00
2023-12-09 18:42:21 +08:00
<p>如果圆和矩形有重叠的部分,请你返回 <code>true</code> ,否则返回 <code>false</code>&nbsp;</p>
2022-03-27 20:37:52 +08:00
2023-12-09 18:42:21 +08:00
<p>换句话说,请你检测是否 <strong>存在</strong><code>(x<sub>i</sub>, y<sub>i</sub>)</code> ,它既在圆上也在矩形上(两者都包括点落在边界上的情况)。</p>
2022-03-27 20:37:52 +08:00
<p>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 1 </strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/02/20/sample_4_1728.png" style="width: 258px; height: 167px;" />
<pre>
<strong>输入:</strong>radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
2022-03-27 20:37:52 +08:00
<strong>输出:</strong>true
2023-12-09 18:42:21 +08:00
<strong>解释:</strong>圆和矩形存在公共点 (1,0) 。
2022-03-27 20:37:52 +08:00
</pre>
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 2 </strong></p>
2022-03-27 20:37:52 +08:00
2023-12-09 18:42:21 +08:00
<pre>
<strong>输入:</strong>radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1
<strong>输出:</strong>false
2022-03-27 20:37:52 +08:00
</pre>
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 3 </strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/02/20/sample_2_1728.png" style="width: 150px; height: 135px;" />
<pre>
<strong>输入:</strong>radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
2022-03-27 20:37:52 +08:00
<strong>输出:</strong>true
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= radius &lt;= 2000</code></li>
2023-12-09 18:42:21 +08:00
<li><code>-10<sup>4</sup> &lt;= xCenter, yCenter &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>4</sup> &lt;= x1 &lt; x2 &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>4</sup> &lt;= y1 &lt; y2 &lt;= 10<sup>4</sup></code></li>
2022-03-27 20:37:52 +08:00
</ul>