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)/连接连续二进制数字 [concatenation-of-consecutive-binary-numbers].html
2022-03-29 12:43:11 +08:00

36 lines
1.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>n</code> ,请你将 <code>1</code> 到 <code>n</code> 的二进制表示连接起来,并返回连接结果对应的 <strong>十进制</strong> 数字对 <code>10<sup>9</sup> + 7</code> 取余的结果。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre><b>输入:</b>n = 1
<b>输出:</b>1
<strong>解释:</strong>二进制的 "1" 对应着十进制的 1 。
</pre>
<p><strong>示例 2</strong></p>
<pre><b>输入:</b>n = 3
<b>输出:</b>27
<strong>解释:</strong>二进制下12 和 3 分别对应 "1" "10" 和 "11" 。
将它们依次连接,我们得到 "11011" ,对应着十进制的 27 。
</pre>
<p><strong>示例 3</strong></p>
<pre><b>输入:</b>n = 12
<b>输出:</b>505379714
<b>解释:</b>连接结果为 "1101110010111011110001001101010111100" 。
对应的十进制数字为 118505380540 。
对 10<sup>9</sup> + 7 取余后,结果为 505379714 。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
</ul>