1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/排列硬币 [arranging-coins].html
2022-03-29 12:43:11 +08:00

30 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>你总共有&nbsp;<code>n</code><em>&nbsp;</em>枚硬币,并计划将它们按阶梯状排列。对于一个由 <code>k</code> 行组成的阶梯,其第 <code>i</code><em> </em>行必须正好有 <code>i</code><em> </em>枚硬币。阶梯的最后一行 <strong>可能</strong> 是不完整的。</p>
<p>给你一个数字&nbsp;<code>n</code><em> </em>,计算并返回可形成 <strong>完整阶梯行</strong> 的总行数。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins1-grid.jpg" style="width: 253px; height: 253px;" />
<pre>
<strong>输入:</strong>n = 5
<strong>输出:</strong>2
<strong>解释:</strong>因为第三行不完整,所以返回 2 。
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/09/arrangecoins2-grid.jpg" style="width: 333px; height: 333px;" />
<pre>
<strong>输入:</strong>n = 8
<strong>输出:</strong>3
<strong>解释:</strong>因为第四行不完整,所以返回 3 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
</ul>