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)/x 的平方根 [sqrtx].html
2022-03-29 12:43:11 +08:00

31 lines
893 B
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>给你一个非负整数 <code>x</code> ,计算并返回&nbsp;<code>x</code>&nbsp;<strong>算术平方根</strong></p>
<p>由于返回类型是整数,结果只保留 <strong>整数部分 </strong>,小数部分将被 <strong>舍去 。</strong></p>
<p><strong>注意:</strong>不允许使用任何内置指数函数和算符,例如 <code>pow(x, 0.5)</code> 或者 <code>x ** 0.5</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>x = 4
<strong>输出:</strong>2
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>x = 8
<strong>输出:</strong>2
<strong>解释:</strong>8 的算术平方根是 2.82842..., 由于返回类型是整数,小数部分将被舍去。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= x &lt;= 2<sup>31</sup> - 1</code></li>
</ul>