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)/统计好数字的数目 [count-good-numbers].html
2022-03-29 12:43:11 +08:00

42 lines
1.6 KiB
HTML
Raw Permalink 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>我们称一个数字字符串是 <strong>好数字</strong> 当它满足(下标从 <strong>0</strong> 开始)<strong>偶数</strong> 下标处的数字为 <strong>偶数</strong> 且 <strong>奇数</strong> 下标处的数字为 <strong>质数</strong> <code>2</code><code>3</code><code>5</code> 或 <code>7</code>)。</p>
<ul>
<li>比方说,<code>"2582"</code> 是好数字,因为偶数下标处的数字(<code>2</code> 和 <code>8</code>)是偶数且奇数下标处的数字(<code>5</code> 和 <code>2</code>)为质数。但 <code>"3245"</code> <strong>不是</strong> 好数字,因为 <code>3</code> 在偶数下标处但不是偶数。</li>
</ul>
<p>给你一个整数 <code>n</code> ,请你返回长度为 <code>n</code> 且为好数字的数字字符串 <strong>总数</strong> 。由于答案可能会很大,请你将它对<strong> </strong><code>10<sup>9</sup> + 7</code> <strong>取余后返回</strong> 。</p>
<p>一个 <strong>数字字符串</strong> 是每一位都由 <code>0</code> 到 <code>9</code> 组成的字符串,且可能包含前导 0 。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>n = 1
<b>输出:</b>5
<b>解释:</b>长度为 1 的好数字包括 "0""2""4""6""8" 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>n = 4
<b>输出:</b>400
</pre>
<p><strong>示例 3</strong></p>
<pre>
<b>输入:</b>n = 50
<b>输出:</b>564908303
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= n <= 10<sup>15</sup></code></li>
</ul>