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)/最小公倍数为 K 的子数组数目 [number-of-subarrays-with-lcm-equal-to-k].html
2022-11-14 20:01:29 +08:00

35 lines
1.3 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>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,请你统计并返回 <code>nums</code><strong>子数组</strong> 中满足 <em>元素最小公倍数为 <code>k</code> </em>的子数组数目。</p>
<p><strong>子数组</strong> 是数组中一个连续非空的元素序列。</p>
<p><strong>数组的最小公倍数</strong> 是可被所有数组元素整除的最小正整数。</p>
<p>&nbsp;</p>
<p><strong>示例 1 </strong></p>
<pre><strong>输入:</strong>nums = [3,6,2,7,1], k = 6
<strong>输出:</strong>4
<strong>解释:</strong>以 6 为最小公倍数的子数组是:
- [<em><strong>3</strong></em>,<em><strong>6</strong></em>,2,7,1]
- [<em><strong>3</strong></em>,<em><strong>6</strong></em>,<em><strong>2</strong></em>,7,1]
- [3,<em><strong>6</strong></em>,2,7,1]
- [3,<em><strong>6</strong></em>,<em><strong>2</strong></em>,7,1]
</pre>
<p><strong>示例 2 </strong></p>
<pre><strong>输入:</strong>nums = [3], k = 2
<strong>输出:</strong>0
<strong>解释:</strong>不存在以 2 为最小公倍数的子数组。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 1000</code></li>
<li><code>1 &lt;= nums[i], k &lt;= 1000</code></li>
</ul>