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)/分数到小数 [fraction-to-recurring-decimal].html
2022-03-29 12:43:11 +08:00

40 lines
1.1 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>numerator</code> 和分母 <code>denominator</code>,以 <strong>字符串形式返回小数</strong></p>
<p>如果小数部分为循环小数,则将循环的部分括在括号内。</p>
<p>如果存在多个答案,只需返回 <strong>任意一个</strong></p>
<p>对于所有给定的输入,<strong>保证</strong> 答案字符串的长度小于 <code>10<sup>4</sup></code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>numerator = 1, denominator = 2
<strong>输出:</strong>"0.5"
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>numerator = 2, denominator = 1
<strong>输出:</strong>"2"
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>numerator = 4, denominator = 333
<strong>输出:</strong>"0.(012)"
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>-2<sup>31</sup> &lt;=&nbsp;numerator, denominator &lt;= 2<sup>31</sup> - 1</code></li>
<li><code>denominator != 0</code></li>
</ul>